1. <div id="test"></div>
    1. // 获取容器节点
    2. const domContainer = document.querySelector('#test')
    3. // 创建虚拟 DOM
    4. const VDOM = <h1 id="title">Hello React!</h1>
    5. // 渲染虚拟 DOM 到页面对应的节点上
    6. ReactDOM.render(VDOM, domContainer)
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    7. <title>Hello React</title>
    8. <script src="./react.development-16.8.4.js"></script>
    9. <script src="./react-dom.development-16.8.4.js"></script>
    10. <script src="../babel/babel.min.js"></script>
    11. </head>
    12. <body>
    13. <div id="test"></div>
    14. <script type="text/babel">
    15. // 获取容器节点
    16. const domContainer = document.querySelector('#test')
    17. // 创建虚拟 DOM
    18. const VDOM = <h1 id="title">Hello React!</h1>
    19. // 渲染虚拟 DOM 到页面对应的节点上
    20. ReactDOM.render(VDOM, domContainer)
    21. </script>
    22. </body>
    23. </html>