详细错误信息如下:
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. ERROR in [eslint] E:\~work_demo\demo_web_sdk\fetch-event-source\src\App.vue 14:5 error The "HelloWorld" component has been registered but not used vue/no-unused-components ✖ 1 problem (1 error, 0 warnings) webpack compiled with 1 error
上面错误信息是由 Vue 的 ESLint 规则 vue/no-unused-components 抛出的,它提示你已经注册了 HelloWorld 组件,但在代码中并没有使用这个组件。
在 Vue 项目里,你可能会在组件里注册其他组件,不过在模板里却没有使用这些已注册的组件。ESLint 的 vue/no-unused-components 规则能够检测到这种情况,并且给出警告或者错误提示,其目的是为了保持代码的简洁,避免不必要的组件注册。
打开 package.json 文件,添加如下配置信息:
{ "rules": { "vue/multi-word-component-names": "off", "vue/no-unused-components": "off" } // ... 其他配置 }