vue—解決“You may use special comments to disable some warnings. Use // eslint-disable-next-line to ...
阿新 • • 發佈:2020-12-19
錯誤描述:
啟動vue專案的時候,出現You may use special comments to disable some warnings. Use // eslint-disable-next-line to …
錯誤原因
ESLint 對語法的要求過於嚴格導致編譯的時候報上圖那些錯誤。
要知道,這並不是程式碼有異常,而是程式碼格式有問題,這些錯誤並不會影響程式碼的執行結果。
解決方法
很簡單,既然是ESLint 語法錯誤,那就取消ESLint驗證規則。
方法1:
如果你的專案是vue腳手架工程,那麼找到專案根目錄下的bulid資料夾 -> webpack.base.conf.js
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []), //註釋掉該行程式碼
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
註釋完儲存退出,重新啟動專案即可。
方法2
當專案並不存在build資料夾,即不屬於vue腳手架工程,那請到根目錄下 config資料夾下的index.js檔案,將useEslint屬性設定為false。
若是不存在useEslint屬性,可以自己新增進去(親測有效)。
改完儲存,重新啟動專案即可。