First React
🏷️ React
安装
安装
NPM
(https://nodejs.org/en/download/)切换到淘宝的
NPM
镜像bashnpm install -g cnpm --registry=https://registry.npm.taobao.org npm config set registry https://registry.npm.taobao.org
1
2安装
create-react-app
模块,快速构建React
开发环境bashcnpm install -g create-react-app create-react-app my-app cd my-app/ npm start
1
2
3
4
Hello, World
修改
src/App.js
为如下内容,保存后之前打开的页面会自动刷新。jsimport React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; class App extends Component { render() { return ( <h1>Hello, world!</h1> ); } } export default App;
1
2
3
4
5
6
7
8
9
10
11
12
13