创建 React脚手架
- 下载React脚手架 : npm install –g create–react-app
- 查看全局npm下载:npm root
- 创建脚手架:create-react-app 项目名
- 进入项目:cd 项目名
- 启动项目:npm start
- 在package.json中可以查看项目中使用的库、启动命令(start)、打包工具(build)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
index.js
import React from 'react'
import ReactDOM from 'react-dom'
import App from './components/app'
import './index.css'
ReactDOM.render(<App />,document.getElementById('root'));