问题出现

新建文章后,复制网上或者原来的代码段过来使用时发现报错 Mixed spaces and tabs no-mixed-spaces-and-tabs

因为大多数代码约定要求使用空格或 tab 进行缩进。因此,一行代码同时混有 tab 缩进和空格缩进,通常是错误的

解决办法

  1. 在工程目录下找到 package.json 文件并打开
  2. 在eslintrcr配置项rules里边手动添加规则 ’no-mixed-spaces-and-tabs’并定义为 0(即关闭检查规则)

    “no-mixed-spaces-and-tabs”:0

补充:使用下面的配置可以减少很多语法检查的报错信息,可以配置使用然后重启项目

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"eslintConfig": {
"root": false,
"env": {
"node": false
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {
"generator-star-spacing": "off",
"no-tabs":"off",
"no-unused-vars":"off",
"no-console":"off",
"no-irregular-whitespace":"off",
"no-debugger": "off",
"no-mixed-spaces-and-tabs":0
}
},

参考链接

  1. Vue报错:Mixed spaces and tabs no-mixed-spaces-and-tabs 解决办法

———————————————-我是分割线—————————————
欢迎到公众号来唠嗑: