vue踩过的坑 ***未使用过no-unuse -vars

今天在写后台管理系统时,封装的数据,在获取用户列表时有个错误

''flag'' is assigned a value but never used no-unused-vars)

Failed to compile.

./src/views/userlist/index.vue
Module Error (from ./node_modules/eslint-loader/index.js):

C:\Users\hasee\Desktop\大实训\后台管理系统\demo\src\views\userlist\index.vue
  297:12  error  'flag' is assigned a value but never used  no-unused-vars

✖ 1 problem (1 error, 0 warnings)

再来看一下我的源码:一直提示我 'flag'被分配了一个值,但从未使用过no-unuse -vars

   //获取用户列表
  async  getUserList() {
     const result=await getUser(this.pageinfo)
      let {flag,result:res}=result;
      if(result.flag === 2) {
          this.tableData = res.users;
          this.pageinfo.pagenum = res.pagenum;
          this.total = res.total;
      }
    },

 

解决方案

在错误代码后加入注释:(// eslint-disable-line no-unused-vars

之后页面上就不会出现该错误信息了

    //获取用户列表
  async  getUserList() {
     const result=await getUser(this.pageinfo)
      let {flag,result:res}=result;// eslint-disable-line no-unused-vars
      if(result.flag === 2) {
          this.tableData = res.users;
          this.pageinfo.pagenum = res.pagenum;
          this.total = res.total;
      }
    },

 

你可能感兴趣的:(vue)