vue踩坑:error 'res' is assigned a value but never used no-unused-vars

2020-04-10 15:52:28 浏览数 (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

代码如下所示

代码语言:javascript复制
methods: {
  async  save(){
    const res = await this.$http.post('categories',this.model) // eslint-disable-line no-unused-vars
    this.$router.push('/categories/list')
    this.$message({
        type:'success',

        message:'保存成功'
    })
    }
},

这个时候就不报错了,页面就能看到了。

0 人点赞