error: Unexpected console statement (no-console) at src\... 解决方法
文章目录
报错的原因是因为代码在js中使用了console.log(),但是Vue.js在使用ESLint检查代码时,发现这个用法不符合ESLint规则,所以报了错。
解决方案1:
找到 eslint-recommended.js ,将"no-console": "off"
这样就不会报错。
解决方案2:
可以在项目根目录下创建一个.eslintrc.js 文件:
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}
这样就可以关掉 no-console 这个错误了。

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论