Vue-cli4.0.x报错Unexpected console statement

尤大大10月22日把脚手架更新到了4.0.5版本,新项目入手4.0版本开发,随后会持续记录4.x版本的坑

只有永远躺在泥坑里的人,才不会掉进坑里

每次看到尤大大在笑我就想哭...,因为又要学新的了.....

代码:

Login: {
        user: "",    //用户名
        password: "" //密码
      },
-------------------------------------------
 watch: {
    Login: {       
      handler(newName, oldName) {
        console.log(newName);
        console.log(oldName);
      },
      deep: true //深度监听
    }
  },

这看似平静的湖面似乎没有什么异常,当回到页面的时候却掀起了万丈波澜

报错内容:Unexpected console statement(意想不到的控制台声明)

error: Unexpected console statement (no-console) at src\components\Login\Login.vue:44:9:
  42 |       handler(newName, oldName) {
  43 |         console.log(newName);
> 44 |         console.log(oldName);
     |         ^
  45 |       },
  46 |       deep: true
  47 |     }

发现问题:

console.log ()/ alert()语法错误

解决问题:

方案①:console.log()改为 window.console.log() 

强烈不推荐,太麻烦;

方案②:src同级目录下 > package.json文件

第24行 eslintConfig:{}  //配置eslint校验规则

rules对象添加属性  "no-console":"off "  

配置完之后,必须重新启动项目,否则不生效!!


如果我的博客帮助你解决了开发问题,请不要吝啬你的小红心哦!


发布了17 篇原创文章 · 获赞 76 · 访问量 9654

猜你喜欢

转载自blog.csdn.net/qq_43471802/article/details/102814996