美文网首页
webpack学习五(react)

webpack学习五(react)

作者: 梦行乌托邦 | 来源:发表于2020-07-11 19:25 被阅读0次

安装

npm install react react-dom --save

修改/src/index.js

import React, {Component} from 'react';
import ReactDom from 'react-dom';

class App extends Component{
    render(){
        return <div>hello world</div>;
    }
}

ReactDom.render(<App/>, document.getElementById('root'));

安装babel与react转换的插件

npm install --save-dev @babel/preset-react

在.babelrc中添加


img1

启动服务,打开浏览器查看,页面上有“hello world”,OK!

相关文章

网友评论

      本文标题:webpack学习五(react)

      本文链接:https://www.haomeiwen.com/subject/uwnicktx.html