A place to hold mainly reading notes, and some technical stuff occasionally. 这里主要是一些读书笔记、感悟;还有部分技术相关的内容。
目录[-]
当创建项目时选择了 eslint
,那么当存在定义而未使用的组件,或存在定义而未使用的变量时,会报错。。
Note: 我用的是 Vue3.0
。
即 eslint
默认规则导致了不必要的报错。
如果开启了 eslint
,新增 Component
时,报错:
The “EchartsDemo” component has been registered but not used vue/no-unused-components
解决方法:在 package.json
或 .eslintrc.js
(如果存在此文件的话)的eslintConfig下添加:
"rules": {
"vue/no-unused-components": "off", // 当存在定义而未使用的组件时,关闭报错
"no-unused-vars":"off" // 当存在定义而未使用的变量时,关闭报错
}
Note:如果两个文件都修改了的话, eslintrc.js
文件的优先级更高。
eslint
?方案一:不使用eslint
,当然,可以在创建项目时不选择 eslint
,可是一般遇到这种问题的,显然是引入了 eslint
。。
方案二:关闭 eslint
,在 vue.config.js
添加一行配置: lintOnSave: false
。
If you have any questions or any bugs are found, please feel free to contact me.
Your comments and suggestions are welcome!