reactJS - 02分离文件

来源:互联网 发布:开一个网络主播工作室 编辑:程序博客网 时间:2024/05/01 04:16

你的 React JSX 代码文件可以写在单独的文件里。创建 src/hello.js 文件,内容如下:

ReactDOM.render(    <h1>Hello,world</h1>,    document.getElementById('demo'));

然后在index.html 引用它

<script type="text/babel" src="src/hello.js"></script>

这里写图片描述
达到了同样的效果,并且我们通过firebug可以注意到发送了一个GET请求我们的hello.js

0 0
原创粉丝点击