运行Vue项目时如果发生Eslint语法检查报错,输出报错内容举例:
Expected indentation of 6 spaces but found 12,可能会是一堆,让人很头疼,如下图所示:
这个问题的解决办法:
在Vue项目文件夹里找到“.eslintrc.js”文件并打开,其内容如下:
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/vue3-essential',
'@vue/standard'
],
parserOptions: {
parser: '@babel/eslint-parser'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}
在其“rules”内增加新规则,并在输出报错的右侧灰色的部分找到所有的命令,增加到 “rules”内,并设置为0,修改后的文件内容如下:
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/vue3-essential',
'@vue/standard'
],
parserOptions: {
parser: '@babel/eslint-parser'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'indent':0,
'comma-dangle':0,
'no-trailing-spaces':0,
'eol-last':0
}
}
修改后,保存,并且重新运行项目,问题应该就是解决了。