原因:定义了变量,或者引入变量并没有使用。所以会触发 eslint 的报错;
解决
办法一
删掉不使用的定义、引入的变量。
办法二
在 package.json 中
{
"name": "...",
"version": "...",
"private": true,
"scripts": {...},
"dependencies": {...},
"devDependencies": {...},
"eslintConfig": {
"root": true,
"env": {...},
"extends": [...],
"parserOptions": {...},
"rules": {
// 加入这一句 关闭这个校验功能,后果是全局其他的地方也不会被校验了
// "off" -> 0 关闭规则
// "warn" -> 1 开启警告规则
// "error" -> 2 开启错误规则
"no-unused-vars":"off"
}
},
"browserslist": [...]
}
重启项目
办法三、
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
您可以使用特殊注释来禁用某些警告。
使用//eslint disable next line忽略下一行。
使用/eslint disable/忽略文件中的所有警告。