因爲是想搭建一個後臺系統,所以組件直接定了antd,腳手架以create-react-app爲基準,加上redux和sass(因爲我一直用的less,這次換個口味),搭建一個簡單的項目。
- 安裝依賴
首先安裝create-react-app
npm i create-react-app
給項目起個名字
create-react-app my_react_cli(項目名)
啪嗒回車,開始安裝項目,此過程會持續幾分鐘,可以去幹點別的~
安裝完成後,就是下圖的樣子了
圖片描述
運行一下看看,有沒有問題
npm start
圖片描述
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-loader": "8.0.4"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
C:\Users\liu\node_modules\babel-loader (version: 7.1.5)
因爲文主之前搭建別的項目時安裝了babel-loader,導致的版本不對,那就卸掉babel-loader,按照所需的8.0.4版本安裝一下
卸載babel-loader
npm uninstall babel-loader
然後安裝正確的版本
npm i [email protected]
可能會出現再次報錯的情況,可以刪掉在你的項目文件夾裏面的 node_modules重新安裝
繼續安裝各種依賴
這裏我暫時裝了[email protected]和[email protected]
運行一下看看
圖片描述
接下里就要開始封裝公共方法
休息一下 有空再寫