Vue注册了组件未使用报错:
component has been registered but not used
报这个错误是因为eslint代码检查到你注册了组件但没有使用,然后就报错了,我们只需要将注册了却未使用的组件取消注册即可。但是我们有时候我们不想取消注册,希望也能编译通过,该怎么处理呢?
有两种方式:
1.修改项目的package.json
在package.json中找到eslintConfig下的rules,增加"vue/no-unused-components": "off"即可:
"eslintConfig": {
"rules": {
"vue/no-unused-components": "off"
}
}
2.如果项目中有eslintrc.js文件,在该js模块中找到rules,增加上"vue/no-unused-components": "off"
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"vue/no-unused-components": "off"
}
这两种使用其中任意一种都可以,如果两个文件都修改了的话,eslintrc.js文件的优先级较高。