安装
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中添加

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