在vue項目中,由于eslint校验比较严格,经常出现Mixed spaces and tabs no-mixed-spaces-and-tabs 这个错误。
出错原因:eslint校验非常严格,不允许使用混合空格和制表符进行缩进。例如:直接这样写,是没有问题。但是如果一旦回车后,就会出错
export default new Vuex.Store({
state: {cityName:"成都"
},
mutations: {
},
actions: {
},
modules: {
}
})
回车以后,便会出错。并且shfit+alt+f格式化以后有时候也不行。
export default new Vuex.Store({
state: {
cityName:"成都"
},
mutations: {
},
actions: {
},
modules: {
}
})
解决办法:eslintrc.js中将这个规则关闭掉
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-mixed-spaces-and-tabs':0
}
}