@vue/cli3中解决Elint中console.log报错的问题

时间:2021-02-01 12:43:32

方法一:package.json中”eslintConfig”>"rules”字段添加如下代码

"no-console": "off",

"no-restricted-syntax": [

"error",

{

"selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",

"message": "Unexpected property on console object was called"

}

]

}

@vue/cli3中解决Elint中console.log报错的问题

方法二:在vue.config.js中添加lintOnSave: false关闭Elint规范

@vue/cli3中解决Elint中console.log报错的问题

方法三:@vue/cli3中接除Elint中不可以用console的开关,或者用window.console.log()代替console.log()即可:

参考地址:https://eslint.org/docs/rules/no-console