vue项目出错:error Expected indentation of 2 spaces but found 4 如何解决

本文介绍了解决Vue项目中因eslint严格模式导致的缩进错误问题,提供了两种解决方案:一是注释掉.eslintrc.js文件中的'@vue/standard'代码;二是通过vueui指令关闭代码检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  这个错误其实是缩进问题,意思是代码规范本来是两个空格,结果却发现了4个。
在这里插入图片描述
  之所以会产生这个问题,是因为创建项目时使用eslint严格模式。这个模式会要求开发者的代码必须按照严格模式的规范编写,如果有空格或者缩进不规范,就会报错。那么如何解决这个问题呢,总不能多个空格缩进就一直报错吧?
  解决方法一:注释严格模式代码(不推荐)
  找到项目中的.eslintrc.js文件,把’@vue/standard’这段代码注释掉或者删掉。
在这里插入图片描述
  解决方法二:关闭代码检查(推荐)
  打开cmd,输入vue ui指令进入vue项目管理界面,找到配置页面,关闭保存时检查按钮,点击刷新即可。
在这里插入图片描述

D:\project\lp_leapcloud_main_web\src\components\Charts\LpCharts.vue 2:22 warning Attribute ":ref" should go before "class" vue/attributes-order 2:22 warning ':ref' should be on a new line vue/max-attributes-per-line 2:33 warning Require self-closing on HTML elements (<div>) vue/html-self-closing 79:5 warning Prop "unit" should define at least its type vue/require-prop-types 104:5 warning Prop 'chartOption' requires default value to be set vue/require-default-prop 143:3 warning The "components" property should be above the "props" property on line 16 vue/order-in-components 154:3 error The `beforeDestroy` lifecycle hook is deprecated. Use `beforeUnmount` instead vue/no-deprecated-destroyed-lifecycle 162:3 error The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead vue/no-deprecated-destroyed-lifecycle ✖ 8 problems (2 errors, 6 warnings) 2 errors and 4 warnings potentially fixable with the `--fix` option. 18:53:51 [vite] warning: D:\project\lp_leapcloud_main_web\src\components\Fault\FaultCase.vue 2:1 warning Expected indentation of 2 spaces but found 4 spaces vue/html-indent 3:1 warning Expected indentation of 4 spaces but found 8 spaces vue/html-indent 3:39 warning 'width' should be on a new line vue/max-attributes-per-line 3:51 warning ':title' should be on a new line vue/max-attributes-per-line 3:66 warning ':before-close' should be on a new line vue/max-attributes-per-line 3:94 warning 'destroy-on-close' should be on a new line vue/max-attributes-per-line 4:1 warning Expected indentation of 6 spaces but found 12 spaces vue/html-indent 4:45 warning 'label-width' should be on a new line vue/max-attributes-per-line 4:65 warning ':model' should be on a new line vue/max-attributes-per-line 4:84 warning Attribute "ref" should go before ":model" vue/attributes-order 4:84 warning 'ref' should be on a new line vue/max-attributes-per-line 4:100 warning ':rules' should be on a new line vue/max-attributes-per-line 5:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 6:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 6:26 warning Expected 1 space after '{{', but not found vue/mustache-interpolation-spacing 6:77 warning Expected 1 space before '}}', but not found vue/mustache-interpolation-spacing 7:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 8:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 9:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 10:1 warning Expected indentation of 12 spaces but found 24 spaces vue/html-indent 10:47 warning Require self-closing on Vue.js custom components (<el-radio>) vue/html-self-closing 11:1 warning Expected indentation of 12 spaces but found 24 spaces vue/html-indent 11:47 warning Require self-closing on Vue.js custom components (<el-radio>) vue/html-self-closing 12:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 13:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 14:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 14:43 warning 'prop' should be on a new line vue/max-attributes-per-line 15:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 15:43 warning Attribute "v-model" should go before "type" vue/attributes-order 15:43 warning 'v-model' should be on a new line vue/max-attributes-per-line 15:52 error Unexpected mutation of "faultForm" prop vue/no-mutating-props 15:73 warning 'maxLength' should be on a new line vue/max-attributes-per-line 15:73 warning Attribute 'maxLength' must be hyphenated vue/attribute-hyphenation 15:83 warning Expected to be enclosed by double quotes vue/html-quotes 15:88 warning 'placeholder' should be on a new line vue/max-attributes-per-line 15:109 warning Require self-closing on Vue.js custom components (<el-input>) vue/html-self-closing 16:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 17:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 17:44 warning 'prop' should be on a new line vue/max-attributes-per-line 18:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 18:47 warning Attribute "v-model" should go before "type" vue/attributes-order 18:47 warning 'v-model' should be on a new line vue/max-attributes-per-line 18:56 error Unexpected mutation of "faultForm" prop vue/no-mutating-props 18:76 warning 'placeholder' should be on a new line vue/max-attributes-per-line 18:98 warning 'maxlength' should be on a new line vue/max-attributes-per-line 18:115 warning Require self-closing on Vue.js custom components (<el-input>) vue/html-self-closing 19:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 20:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 20:44 warning 'prop' should be on a new line vue/max-attributes-per-line 21:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 21:47 warning Attribute "v-model" should go before "type" vue/attributes-order 21:47 warning 'v-model' should be on a new line vue/max-attributes-per-line 21:56 error Unexpected mutation of "faultForm" prop vue/no-mutating-props 21:74 warning 'placeholder' should be on a new line vue/max-attributes-per-line 21:96 warning 'maxlength' should be on a new line vue/max-attributes-per-line 21:113 warning Require self-closing on Vue.js custom components (<el-input>) vue/html-self-closing 22:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 23:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 24:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 24:44 warning '@click' should be on a new line vue/max-attributes-per-line 24:66 warning Expected 1 line break after opening tag (`<el-button>`), but no line breaks found vue/singleline-html-element-content-newline 24:68 warning Expected 1 line break before closing tag (`</el-button>`), but no line breaks found vue/singleline-html-element-content-newline 25:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 25:47 warning '@click' should be on a new line vue/max-attributes-per-line 25:67 warning Expected 1 line break after opening tag (`<el-button>`), but no line breaks found vue/singleline-html-element-content-newline 25:69 warning Expected 1 line break before closing tag (`</el-button>`), but no line breaks found vue/singleline-html-element-content-newline 26:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 27:1 warning Expected indentation of 6 spaces but found 12 spaces vue/html-indent 28:1 warning Expected indentation of 4 spaces but found 8 spaces vue/html-indent 29:1 warning Expected indentation of 2 spaces but found 4 spaces vue/html-indent 38:9 warning Prop 'title' requires default value to be set vue/require-default-prop 39:9 warning Prop 'faultForm' requires default value to be set vue/require-default-prop 51:9 warning Prop 'parentFunc' requires default value to be set vue/require-default-prop 99:24 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 122:44 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 127:44 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 136:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 140:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 148:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 152:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 164:5 warning The "destroyed" property should be above the "methods" property on line 97 vue/order-in-components 164:5 error The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead vue/no-deprecated-destroyed-lifecycle ✖ 82 problems (4 errors, 78 warnings) 1 error and 56 warnings potentially fixable with the `--fix` option. Plugin: vite-plugin-eslint File: D:/project/lp_leapcloud_main_web/src/components/Fault/FaultCase.vue D:\project\lp_leapcloud_main_web\src\components\Fault\FaultCase.vue 2:1 warning Expected indentation of 2 spaces but found 4 spaces vue/html-indent 3:1 warning Expected indentation of 4 spaces but found 8 spaces vue/html-indent 3:39 warning 'width' should be on a new line vue/max-attributes-per-line 3:51 warning ':title' should be on a new line vue/max-attributes-per-line 3:66 warning ':before-close' should be on a new line vue/max-attributes-per-line 3:94 warning 'destroy-on-close' should be on a new line vue/max-attributes-per-line 4:1 warning Expected indentation of 6 spaces but found 12 spaces vue/html-indent 4:45 warning 'label-width' should be on a new line vue/max-attributes-per-line 4:65 warning ':model' should be on a new line vue/max-attributes-per-line 4:84 warning Attribute "ref" should go before ":model" vue/attributes-order 4:84 warning 'ref' should be on a new line vue/max-attributes-per-line 4:100 warning ':rules' should be on a new line vue/max-attributes-per-line 5:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 6:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 6:26 warning Expected 1 space after '{{', but not found vue/mustache-interpolation-spacing 6:77 warning Expected 1 space before '}}', but not found vue/mustache-interpolation-spacing 7:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 8:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 9:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 10:1 warning Expected indentation of 12 spaces but found 24 spaces vue/html-indent 10:47 warning Require self-closing on Vue.js custom components (<el-radio>) vue/html-self-closing 11:1 warning Expected indentation of 12 spaces but found 24 spaces vue/html-indent 11:47 warning Require self-closing on Vue.js custom components (<el-radio>) vue/html-self-closing 12:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 13:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 14:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 14:43 warning 'prop' should be on a new line vue/max-attributes-per-line 15:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 15:43 warning Attribute "v-model" should go before "type" vue/attributes-order 15:43 warning 'v-model' should be on a new line vue/max-attributes-per-line 15:52 error Unexpected mutation of "faultForm" prop vue/no-mutating-props 15:73 warning 'maxLength' should be on a new line vue/max-attributes-per-line 15:73 warning Attribute 'maxLength' must be hyphenated vue/attribute-hyphenation 15:83 warning Expected to be enclosed by double quotes vue/html-quotes 15:88 warning 'placeholder' should be on a new line vue/max-attributes-per-line 15:109 warning Require self-closing on Vue.js custom components (<el-input>) vue/html-self-closing 16:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 17:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 17:44 warning 'prop' should be on a new line vue/max-attributes-per-line 18:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 18:47 warning Attribute "v-model" should go before "type" vue/attributes-order 18:47 warning 'v-model' should be on a new line vue/max-attributes-per-line 18:56 error Unexpected mutation of "faultForm" prop vue/no-mutating-props 18:76 warning 'placeholder' should be on a new line vue/max-attributes-per-line 18:98 warning 'maxlength' should be on a new line vue/max-attributes-per-line 18:115 warning Require self-closing on Vue.js custom components (<el-input>) vue/html-self-closing 19:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 20:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 20:44 warning 'prop' should be on a new line vue/max-attributes-per-line 21:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 21:47 warning Attribute "v-model" should go before "type" vue/attributes-order 21:47 warning 'v-model' should be on a new line vue/max-attributes-per-line 21:56 error Unexpected mutation of "faultForm" prop vue/no-mutating-props 21:74 warning 'placeholder' should be on a new line vue/max-attributes-per-line 21:96 warning 'maxlength' should be on a new line vue/max-attributes-per-line 21:113 warning Require self-closing on Vue.js custom components (<el-input>) vue/html-self-closing 22:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 23:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 24:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 24:44 warning '@click' should be on a new line vue/max-attributes-per-line 24:66 warning Expected 1 line break after opening tag (`<el-button>`), but no line breaks found vue/singleline-html-element-content-newline 24:68 warning Expected 1 line break before closing tag (`</el-button>`), but no line breaks found vue/singleline-html-element-content-newline 25:1 warning Expected indentation of 10 spaces but found 20 spaces vue/html-indent 25:47 warning '@click' should be on a new line vue/max-attributes-per-line 25:67 warning Expected 1 line break after opening tag (`<el-button>`), but no line breaks found vue/singleline-html-element-content-newline 25:69 warning Expected 1 line break before closing tag (`</el-button>`), but no line breaks found vue/singleline-html-element-content-newline 26:1 warning Expected indentation of 8 spaces but found 16 spaces vue/html-indent 27:1 warning Expected indentation of 6 spaces but found 12 spaces vue/html-indent 28:1 warning Expected indentation of 4 spaces but found 8 spaces vue/html-indent 29:1 warning Expected indentation of 2 spaces but found 4 spaces vue/html-indent 38:9 warning Prop 'title' requires default value to be set vue/require-default-prop 39:9 warning Prop 'faultForm' requires default value to be set vue/require-default-prop 51:9 warning Prop 'parentFunc' requires default value to be set vue/require-default-prop 99:24 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 122:44 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 127:44 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 136:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 140:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 148:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 152:48 warning The "update:visible" event has been triggered but not declared on `emits` option vue/require-explicit-emits 164:5 warning The "destroyed" property should be above the "methods" property on line 97 vue/order-in-components 164:5 error The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead vue/no-deprecated-destroyed-lifecycle ✖ 82 problems (4 errors, 78 warnings) 1 error and 56 warnings potentially fixable with the `--fix` option. 18:53:51 [vite] warning: D:\project\lp_leapcloud_main_web\src\components\CarSearch\CommChartHeader.vue 8:17 warning Attribute ':isClearable' must be hyphenated vue/attribute-hyphenation 8:44 warning ':carType.sync' should be on a new line vue/max-attributes-per-line 8:44 warning Attribute ':carType.sync' must be hyphenated vue/attribute-hyphenation 8:44 error '.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead vue/no-deprecated-v-bind-sync 8:82 warning 'isNormal' should be on a new line vue/max-attributes-per-line 8:82 warning Attribute 'isNormal' must be hyphenated vue/attribute-hyphenation 8:91 warning 'style' should be on a new line vue/max-attributes-per-line 8:117 warning Require self-closing on Vue.js custom components (<car-type>) vue/html-self-closing 9:43 warning Attribute "v-model" should go before "class" vue/attributes-order 9:43 warning 'v-model' should be on a new line vue/max-attributes-per-line 9:80 warning 'align' should be on a new line vue/max-attributes-per-line 9:94 warning 'type' should be on a new line vue/max-attributes-per-line 9:106 warning 'placeholder' should be on a new line vue/max-attributes-per-line 9:129 warning ':picker-options' should be on a new line vue/max-attributes-per-line 9:161 warning Require self-closing on Vue.js custom components (<el-date-picker>) vue/html-self-closing 10:50 warning 'class' should be on a new line vue/max-attributes-per-line 10:81 warning ':vinOrNum.sync' should be on a new line vue/max-attributes-per-line 10:81 warning Attribute ':vinOrNum.sync' must be hyphenated vue/attribute-hyphenation 10:81 error '.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead vue/no-deprecated-v-bind-sync 10:117 warning ':multiple' should be on a new line vue/max-attributes-per-line 10:134 warning ':carType' should be on a new line vue/max-attributes-per-line 10:134 warning Attribute ':carType' must be hyphenated vue/attribute-hyphenation 10:167 warning Require self-closing on Vue.js custom components (<car-select>) vue/html-self-closing 11:18 warning Attribute ':componentData' must be hyphenated vue/attribute-hyphenation 11:49 warning Require self-closing on Vue.js custom components (<car-miles>) vue/html-self-closing 12:33 warning '@click' should be on a new line vue/max-attributes-per-line 12:48 warning Expected 1 line break after opening tag (`<el-button>`), but no line breaks found vue/singleline-html-element-content-newline 12:50 warning Expected 1 line break before closing tag (`</el-button>`), but no line breaks found vue/singleline-html-element-content-newline 23:5 warning Prop 'onOk' requires default value to be set vue/require-default-prop 26:5 warning Prop 'carType' requires default value to be set vue/require-default-prop 36:3 warning The "data" property should be above the "mounted" property on line 33 vue/order-in-components 54:3 warning The "components" property should be above the "props" property on line 22 vue/order-in-components 55:5 error The "LpArea" component has been registered but not used vue/no-unused-components ✖ 33 problems (3 errors, 30 warnings) 2 errors and 17 warnings potentially fixable with the `--fix` option. Plugin: vite-plugin-eslint File: D:/project/lp_leapcloud_main_web/src/components/CarSearch/CommChartHeader.vue D:\project\lp_leapcloud_main_web\src\components\CarSearch\CommChartHeader.vue 8:17 warning Attribute ':isClearable' must be hyphenated vue/attribute-hyphenation 8:44 warning ':carType.sync' should be on a new line vue/max-attributes-per-line 8:44 warning Attribute ':carType.sync' must be hyphenated vue/attribute-hyphenation 8:44 error '.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead vue/no-deprecated-v-bind-sync 8:82 warning 'isNormal' should be on a new line vue/max-attributes-per-line 8:82 warning Attribute 'isNormal' must be hyphenated vue/attribute-hyphenation 8:91 warning 'style' should be on a new line vue/max-attributes-per-line 8:117 warning Require self-closing on Vue.js custom components (<car-type>) vue/html-self-closing 9:43 warning Attribute "v-model" should go before "class" vue/attributes-order 9:43 warning 'v-model' should be on a new line vue/max-attributes-per-line 9:80 warning 'align' should be on a new line vue/max-attributes-per-line 9:94 warning 'type' should be on a new line vue/max-attributes-per-line 9:106 warning 'placeholder' should be on a new line vue/max-attributes-per-line 9:129 warning ':picker-options' should be on a new line vue/max-attributes-per-line 9:161 warning Require self-closing on Vue.js custom components (<el-date-picker>) vue/html-self-closing 10:50 warning 'class' should be on a new line vue/max-attributes-per-line 10:81 warning ':vinOrNum.sync' should be on a new line vue/max-attributes-per-line 10:81 warning Attribute ':vinOrNum.sync' must be hyphenated vue/attribute-hyphenation 10:81 error '.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead vue/no-deprecated-v-bind-sync 10:117 warning ':multiple' should be on a new line vue/max-attributes-per-line 10:134 warning ':carType' should be on a new line vue/max-attributes-per-line 10:134 warning Attribute ':carType' must be hyphenated vue/attribute-hyphenation 10:167 warning Require self-closing on Vue.js custom components (<car-select>) vue/html-self-closing 11:18 warning Attribute ':componentData' must be hyphenated vue/attribute-hyphenation 11:49 warning Require self-closing on Vue.js custom components (<car-miles>) vue/html-self-closing 12:33 warning '@click' should be on a new line vue/max-attributes-per-line 12:48 warning Expected 1 line break after opening tag (`<el-button>`), but no line breaks found vue/singleline-html-element-content-newline 12:50 warning Expected 1 line break before closing tag (`</el-button>`), but no line breaks found vue/singleline-html-element-content-newline 23:5 warning Prop 'onOk' requires default value to be set vue/require-default-prop 26:5 warning Prop 'carType' requires default value to be set vue/require-default-prop 36:3 warning The "data" property should be above the "mounted" property on line 33 vue/order-in-components 54:3 warning The "components" property should be above the "props" property on line 22 vue/order-in-components 55:5 error The "LpArea" component has been registered but not used vue/no-unused-components ✖ 33 problems (3 errors, 30 warnings) 2 errors and 17 warnings potentially fixable with the `--fix` option. 18:53:52 [vite] warning: D:\project\lp_leapcloud_main_web\src\App.vue 2:1 warning Expected indentation of 2 spaces but found 4 spaces vue/html-indent 3:1 warning Expected indentation of 4 spaces but found 8 spaces vue/html-indent 3:22 warning Require self-closing on Vue.js custom components (<router-view>) vue/html-self-closing 4:1 warning Expected indentation of 2 spaces but found 4 spaces vue/html-indent ✖ 4 problems (0 errors, 4 warnings) 0 errors and 4 warnings potentially fixable with the `--fix` option. Plugin: vite-plugin-eslint File: D:/project/lp_leapcloud_main_web/src/App.vue?vue&type=style&index=0&lang.css 是不是vue2不应该迁移vite
最新发布
07-01
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值