Reactjs ES5中的react-webcam

时间:2018-09-08 17:10:16

标签: javascript reactjs socket.io ecmascript-5

我是Reactjs的新手,我正在尝试制作一个访问网络摄像头的小型localhost Web应用程序。我找到了一个有效的示例here。我已经尝试在Reactjs ES5和SocketIO中实现它,如下所示,

app.js

socket.on('sessionstarted', function (data) {
    ReactDOM.render( <div><Webcam /></div>, document.getElementById('root'));
    reactCookie.save('sid', data.id);
});

home.ejs

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Virtual Classroom</title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/style.css">
        <!--<script type="text/javascript" src="js/jquery.min.js"></script>-->
        <!--<script type="text/javascript" src="js/bootstrap.min.js"></script>-->
        <script type="text/javascript" src="js/socket.io-1.4.5.js"></script>
        <script type="text/javascript" src="js/react.js"></script>
        <script type="text/javascript" src="js/react-webcam.js"></script>
        <script type="text/javascript" src="js/react-dom.js"></script>
        <script type="text/javascript" src="js/react-cookie.min.js"></script>
        <script type="text/javascript" src="js/axios.min.js"></script>
        <script type="text/javascript" src="js/babel.min.js"></script>
        <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
        <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
        <script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>
        <script src="https://unpkg.com/react-webcam@1.0.1/dist/react-webcam.min.js"></script>
    </head>
    <body>
        <div id="root"></div>
        <script src="js/app.js" type="text/babel"></script>
    </body>
</html>

此实现似乎无效。我非常感谢您的帮助。

0 个答案:

没有答案