yarn run eject時
Remove untracked files, stash or commit any changes, and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! devportalfrontend@0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the devportalfrontend@0.1.0 eject script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/deep/.npm/_logs/2018-02-18T17_05_02_924Z-debug.log
Uninstalling react-scripts and installing react-scripts-cssmodules solved the problem
npm uninstall react-scripts
npm install react-scripts-cssmodules
npm run eject
運行第一個命令時報錯奶栖,權(quán)限錯誤恶守,關(guān)閉后用管理員模式打開運行
git add .
git commit -am "Save before ejecting"
成功
代碼問題
1.圖片img路徑問題
將圖片名稱當(dāng)做參數(shù)傳入.png
獲取參數(shù)余佃,將選中圖片地址保存在state中.png
在img中獲取圖片地址
運行報錯
報錯.png
require后的()中接收的是string類型捐友,可能state保存的是object類型
解決方法:將require一起存入state中
handleOpen=(img)=>{
this.setState({
visible:true,
currentImg:require('../../resource/assets/img/gallery/'+img),
})
}
4.commit時報錯
pre-commit的報錯
解決:刪除.git里的pre-commit文件澎怒,不是萬全之策用含,嘗試其他解決辦法