1. 程式人生 > 其它 >vue3.0常見報錯解決

vue3.0常見報錯解決

技術標籤:vue專案中報錯處理vue報錯處理vue3.0 執行報錯

1.報錯:This dependency was not found: vue-router in ./src/router/Index.js
原因:vue-router 沒有安裝
執行:npm install --save vue-router
在這裡插入圖片描述
2.報錯:Failed to resolve loader: less-loader You may need to install it. 或者Syntax Error: Error: Cannot find module ‘less’
原因:less-loader 沒有安裝
執行:npm install less less-loader --save-dev


在這裡插入圖片描述在這裡插入圖片描述
3. 報錯:Syntax Error: TypeError: this.getOptions is not a function
原因:less-loader版本太高
解決:

npm uninstall less-loader   //解除安裝less-loader  
npm install [email protected]   //執行

4.error Irregular whitespace not allowed no-irregular-whitespace
原因:eslint 不規則空格引起的錯誤;
解決方法一:格式化檔案 右鍵選擇Format Domcument With… 選擇 prettier-Code formatter 儲存檔案解決

在這裡插入圖片描述
解決方法二:在package.json檔案的eslintConfig配置或者在.eslintrc.js中找到rules位置修改
在這裡插入圖片描述