Rumah  >  Soal Jawab  >  teks badan

javascript - REACT.JS 不是这么用的吗,我引用错了?咋显示不出来

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="js/react.js"></script>
    <script src="js/react-dom.js"></script>
</head>
<body>
 <p id="example"></p> 
 <script type="text/babel">
     ReactDOM.render( <h1>Hello, world!</h1>, document.getElementById('example') );
 </script>
</body>
</html>
PHPzPHPz2771 hari yang lalu249

membalas semua(2)saya akan balas

  • PHPz

    PHPz2017-04-11 13:17:17

    你缺少了babel解析器,详细看http://reactjs.cn/react/docs/...

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <title>Hello React!</title>
        <script src="build/react.js"></script>
        <script src="build/react-dom.js"></script>
        <script src="https://npmcdn.com/babel-core@5.8.38/browser.min.js"></script>
      </head>
      <body>
        <p id="example"></p>
        <script type="text/babel">
          ReactDOM.render(
            <h1>Hello, world!</h1>,
            document.getElementById('example')
          );
        </script>
      </body>
    </html>

    balas
    0
  • 大家讲道理

    大家讲道理2017-04-11 13:17:17

    缺少Browser.js ,需要将JSX转化成javascript
    不懂的话看https://github.com/ruanyf/rea... 就明白了

    balas
    0
  • Batalbalas