vue语法检查工具eslint报错小记(error Unexpected trailing comma、Extra semicolon、error ‘loadingInstance‘ is nev)

vue语法检查工具eslint报错小记

vue项目开发中开启语法检查工具eslint,尤其是接手别人的代码继续开发时,如果不注意语法习惯,项目运行时会出现一堆warning、error,乍一看就头大,仔细以看也没啥。
在这里插入图片描述

一、语法检查工具eslint的常用报错:
1、“66:1 warning Expected indentation of 6 spaces but found 8 spaces”
此类报错是语法缩进问题,语法检查工具eslint对每行的缩进空格有严格计算,多一格就warning黄牌警告。前边的数字是提示报警的位置,在文件第几行第几个字符,便于定位,每一条报错都会有。

2、“97:22 error Unexpected trailing comma
尾部意外出现多余逗号。
语法检查工具eslint对符号也有严格限制,每一行代码,如果不是语法需要,最后加上逗号或者分号结尾,会被判定多余,不影响运行,但是会error红牌。
类似的还有**“Extra semicolon”**额外分号。

3、“117:24 error Unexpected space before function parentheses”
函数括号前出现意外空格

4、“143:60 error Strings must use singlequote”
字符串必须使用单引号

猜你喜欢

转载自blog.csdn.net/start_sea/article/details/129706863