1. 程式人生 > 其它 >vue—解決“You may use special comments to disable some warnings. Use // eslint-disable-next-line to ...

vue—解決“You may use special comments to disable some warnings. Use // eslint-disable-next-line to ...

技術標籤:vuevue

錯誤描述:
啟動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屬性,可以自己新增進去(親測有效)。

改完儲存,重新啟動專案即可。