简体   繁体   English

如何从我的 react-app 启动节点脚本?

[英]How can i start node script from my react-app?

What is the easiest way to launch a node.js script from a react-app by using a button?使用按钮从 react-app 启动 node.js 脚本的最简单方法是什么?

I've a simple app with two buttons - using Material.io我有一个带有两个按钮的简单应用程序 - 使用 Material.io

export default function ButtonsMenu() {
    const classes = useStyles();

    return (
    <Grid>
        <Grid item xs={12}>
            <Paper style={styles.Paper}>
                <Button onClick={activeLights} variant="contained" color="primary" className={classes.button}>
                    ON
                </Button>
                <Button onClick={inactiveLights}variant="contained" color="secondary" className={classes.button}>
                    OFF
                </Button>
            </Paper>
        </Grid>
    </Grid>
    );

I also have an Arduino with led stripe that i wrote a node.js code for.我还有一个带 LED 条纹的 Arduino,我为其编写了 node.js 代码。 How can i run it from the browser?如何从浏览器运行它?

I know that i need a node server and a client, but need some help what should i do next.我知道我需要一个节点服务器和一个客户端,但需要一些帮助我接下来应该做什么。

I would appreciate any github repository etc.我将不胜感激任何 github 存储库等。

You can't do that, ReactJs is for fornt using, but instead make an API call to a node js server, even the browser will block you from calling local commands你不能这样做,ReactJs 是fornt使用,而是对节点js服务器进行API调用,即使浏览器也会阻止你调用本地命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM