Vue的Eslint中常见的报错解决方法

语法错误

"TypeError: Cannot read property 'resetFields' of undefined"

关键字前面的值变成了undefined

property or method "isCollapse" is not defined on the instance but referenced during render.
Property or method "a" is not defined on the instance but referenced during render.

关键字在页面中使用了,但是没有在data或methods中定义, 使用的和定义的名字不一致

Module not found: Error: Can't resolve './views/User/index.vue' 

当前的路径错误,仔细核对路径

<el-card> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

没有注册(导入该组件),或者导入注册组件的名字和使用的名字不一致

在项目打包之后,项目运行不起来,路径出了问题,通过下面方式解决

vue.config.js
module.export = {
  publicPath: './'
}

eslint常见错误

Too many blank lines at the end of file

结尾处换行超过1行

Newline required at end of file but not found

结尾处没有新的换行

Missing space before value for key 'render'

丢失了空格在key的冒号后面

Strings must use singlequote

必须是单引号

Trailing spaces not allowed

当前行末尾处有多余的空格

Expected indentation of 8 spaces but found 10

当前行希望是前面有8个空格缩进但是有10个空格缩进

'Login' is defined but never used

定义了Login, 但是没有使用到

F:课程课程项目vueadmin_13src
outerindex.js
28:20  error  'Welcome' is not defined  no-undef

在路由的js中出现这个错误,那么就是使用了这个组件,没有定义导入进来,或者就是导入组件接收的名字和使用的时候不一致

More than 1 blank line not allowed

不允许换行超过1次, 只能有一行换行

Unexpected trailing comma

结尾处多了一个逗号

Extra semicolon

结尾处多了分号

Missing space before function parentheses

方法简写的()前面没有空格

Missing space before opening brace

方法简写的{}前面没有空格

时间如白驹过隙,忽然而已,且行且珍惜......
原文地址:https://www.cnblogs.com/UnfetteredMan/p/13950850.html