1.windows安装,

安装React 需要在计算机上安装 Node.js >= 6 和 npm >= 5.2

cmd --> node -v

cmd -->npm -v

React 开发环境搭建

2.国内使用 npm 速度很慢,可以使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:

npm install -g cnpm --registry=https://registry.npm.taobao.org

npm config set registry https://registry.npm.taobao.org

React 开发环境搭建

3.全局安装: cnpm install -g create-react-app

React 开发环境搭建

4.create-react-app my-app

React 开发环境搭建

React 开发环境搭建

5.cd my && npm run

React 开发环境搭建

此时服务器已经启动:

http://localhost:3000/

可以看到正常的页面已经出来了。

至此,我们已成功搭建React 开发环境。

接下来,我们来看下目录结构:

React 开发环境搭建

src目录结构:

React 开发环境搭建

然后我们做一些小的修改:在App.js中

React 开发环境搭建

保存,打卡页面(页面会自动刷新),

React 开发环境搭建

同时,React 可以直接下载使用,用<script>标签添加到HTML页面中,

可以在官网 https://reactjs.org/ 下载最新版。

 

 

 

 

相关文章:

  • 2022-01-16
  • 2021-09-15
  • 2021-06-21
  • 2022-12-23
  • 2022-01-08
  • 2021-05-11
猜你喜欢
  • 2021-06-05
  • 2021-09-04
  • 2022-12-23
  • 2021-06-14
相关资源
相似解决方案