Vue中:error 'XXXXX' is not defined no-undef解決辦法


Vue中:error 'XXXXX' is not defined no-undef解決辦法

報錯內容:

× Client
  Compiled with some errors in 7.42s
√ Server
  Compiled successfully in 6.05s
 ERROR  Failed to compile with 1 errors                                                                               friendly-errors 17:33:15  
 ERROR  in ./pages/player/_vid.vue                                                                                friendly-errors 17:33:15  
Module Error (from ./node_modules/eslint-loader/index.js):                                                                                friendly-errors 17:33:15  
E:\java\JavaWorkSpace\OnlineEducation\WebReview\vue-front-1010\pages\player\_vid.vue
  28:9  error  'Aliplayer' is not defined  no-undef
✖ 1 problem (1 error, 0 warnings)

報錯截圖:

解決辦法:

在使用vue的時候,使用一個全局變量,ESLint的語法會出現ESLint: 'Aliplayer' is not defined. (no-undef),說變量未定義,這時我們可以添加配置,取消這個校驗。在.eslintrc.js文件中添加一個配置,位置如下圖所示,我的全局變量就是Aliplayer。

在eslintrc.js中的module.exports內添加如下代碼塊:

  "globals":{
    "Aliplayer": true
  }

位置如下:

module.exports = {
  root: true,
  parserOptions: {
  xxxxxx
  },
  env: {
  xxxxxx
  },
  rules: {
  xxxxxx
  },
  "globals":{
    "Aliplayer": true
  }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM