创建环境--react脚手架


一、前提

  1.需要安装node.js,地址:https://nodejs.org/en/download/

  2.需要安装yarn环境

  (1)在cmd 中输入 npm install yarn -g

  都安装好后就可以在cmd中输入 npm -g create-react-app

  3.遇到问题,都安装好了,但是就是安装不了create-react-app 解决方法:用npx create-react-app 文件名(最好都用小写)就可以解决了

二、过程

  1.用cmd创建文件 create-react-app 文件名

  2.用vs打开该文件夹

  3.在vs里的中端输入 yarn start 会跳转到网页 有react的图标

 4.理解文件夹的index.html的代码

 1 
 2 
 3   
 4     
 5     
 6     
 7     
 8     
 9     
10     
11     
12     <meta
13       name="description"
14       content="Web site created using create-react-app"
15     />
16     
17     
18     
19     
20   
21     React App
22   
23   
24     
25     
26       
27     
28 29 30

5.src理解

App.css -------- App组件的样式

                        App.js --------- App组件

                        App.test.js ---- 用于给App做测试

                        index.css ------ 样式

                        index.js ------- 入口文件

                        logo.svg ------- logo图

                        reportWebVitals.js

                                       --- 页面性能分析文件(需要web-vitals库的支持)

                        setupTests.js

                                       ---- 组件单元测试的文件(需要jest-dom库的支持)