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中:error  'XXXXX' is not defined  no-undef解决办法

解决办法:

在使用vue的时候,使用一个全局变量,ESLint的语法会出现ESLint: 'Aliplayer' is not defined. (no-undef),说变量未定义,这时我们可以添加配置,取消这个校验。在.eslintrc.js文件中添加一个配置,位置如下图所示,我的全局变量就是Aliplayer。
Vue中:error  'XXXXX' is not defined  no-undef解决办法

在eslintrc.js中的module.exports内添加如下代码块:

  "globals":{
    "Aliplayer": true
  }

位置如下:

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

Vue中:error  'XXXXX' is not defined  no-undef解决办法

上一篇:打包时Lint found fatal errors while assembling a release target错误别在设置禁止检测了


下一篇:序列化器类验证的三种常用方式以及is_valid()函数的源码解析