安装脚手架工具
npm install create-react-app -g
创建一个新的工程
create-react-app 工程名称
到工程文件夹中,运行该工程
npm start
我们建一个welcome.js
import React from ‘react‘ class Welcome extends React.Component{ render(){ return <h1>Hello React</h1> } } //导出整个类 export default Welcome;
在index.js中引入welcome即可
原文:https://www.cnblogs.com/360School/p/14807964.html