React基本项目创建
基本搭建
在创建之前,需要有一个git 仓库,我们要把项目搭建到git 中
步骤
第一步:git clone 链接 远程仓库
第二步:cd 文件名 到仓库文件下
第三步:确认node 版本(node -v)【使用nvm use v14 切换】
第四步:npx create-react-app first-react(first-react是要创建的文件名)
第五步:git add --all 提交所有文件
git commit -m ‘up’
第六步:cd first-react
第七步:yarn eject (配置文件)输入y
mkdir 建文件夹
cd … 返回上一级目录
cd first-react 进入first-react目录
ls 看这个文件夹里有什么
安装sass:
yarn add node-sass-chokidar
yarn add npm-run-all
在package.json里更改
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive --use-polling --polling-interval 1000",
"start-js": "node scripts/start.js",
"start": "npm-run-all -p watch-css start-js",
"build-js": "node scripts/build.js",
"build": "npm-run-all build-css build-js",
"test": "node scripts/test.js --env=jsdom"
},
src下面创建style/index.scss —引入到index.js
src/view/home/index.jsx — 引入到app.js
app.js里写路由
router.js里引app.js
proxy代理,setupProxy.js