eslint 踩坑 -- error '***' is assigned a value but never used no-unused-vars

2021-10-25 10:30:49 浏览数 (1)

写代码的时候,遇到了这样的一个报错

代码语言:javascript复制
 
 error  in ./src/views/CategoryEdit.vue
 
Module Error (from ./node_modules/eslint-loader/index.js):
 
D:node-vue-mobaadminsrcviewsCategoryEdit.vue
  24:11  error  'res' is assigned a value but never used  no-unused-vars
 
✖ 1 problem (1 error, 0 warnings)
✖ 1 problem (1 error, 0 warnings)
 
 
 @ ./src/router/index.js 4:0-53 13:15-27
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.0.121:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
 

错误原因:eslint的验证语法

解决办法:在错误语句后添加注释

代码语言:javascript复制
// eslint-disable-line no-unused-vars

代码如下所示

这样就不报错了!

但是,如果页面有很多的 效验不通过,我们不会去选择 一个个的修改。所以,必要的时候要修改eslint 规则 ( https://cloud.tencent.com/developer/article/1892931 )

0 人点赞