源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Hello React!</title> <script src="../static/js/react.production.min.js" ></script> <script src="../static/js/react-dom.production.min.js"></script> <script src="../static/js/babel.min.js" ></script> </head> <body> <div id="example"></div> <script type="text/babel"> // 简单的 React 组件 function App() { return <h1>Hello, React!</h1>; } const root = ReactDOM.createRoot(document.getElementById("example")); // 渲染 React 组件到 DOM root.render(<App />); </script> </body> </html>
运行结果: