原因:

​​eslint​​代码检查到你注册了组件但没有使用,然后就报错了。比如代码:

比如​​Vue​​​中注册了​​File​​组件,而实际上却没有使用到(直接取消注册为好):

...
import File from "../../components/file";
export default {
components: {Pagination, File},
...

此时你可以取消注册即可,当然,有些时候我们并不想要取消,不更改代码,可以有两种解决办法:

方法一:

修改项目的​​package.json​​

在​​package.json​​中找到​​eslintConfig​​下的​​rules​​,增加​​"vue/no-unused-components": "off"​​即可:

"eslintConfig": {
"rules": {
"vue/no-unused-components": "off"
}
}

方法二:

如果项目中有​​eslintrc.js​​文件,也是一样添加上即可:

rules: {
"vue/no-unused-components": "off"
}

这两种使用其中任意一种都可以,修改好后重新启动一下项目,注意:如果两个文件都修改了的话,​​eslintrc.js​​文件的优先级更高。

Vue报错:component has been registered but not used的更多相关文章

  1. Vue报错——“Trailing spaces not allowed”

    在VSCode中开发Vue 报错:“Trailing spaces not allowed” 这是空格多了,删除多余的空格就可以了

  2. vue 报错 :属性undefined(页面成功渲染)

    vue 报错:Cannot read property 'instrumentId' of undefined" 相关代码如下: <template> ... <span& ...

  3. Vue 报错Error in render: “TypeError: Cannot read properties of null (reading ‘xxx’)” found in

    前端vue报错 [Vue warn]: Error in render: "TypeError: Cannot read properties of null (reading 'name' ...

  4. Vue报错 type check failed for prop “xxx“. Expected String with value “xx“,got Number with value ‘xx‘

    vue报错    [Vue warn]: Invalid prop: type check failed for prop "name". Expected String with ...

  5. Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')

    Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...

  6. vue报错[Vue warn]: Unknown custom element: <router-Link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

    vue浏览器报错,如下 vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <router-Link> - di ...

  7. VUE编译报错 Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead

    背景: 在使用VUE添加标签的时候编译报错,报错如下: Component template should contain exactly one root element. If you are u ...

  8. vue报错:Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

    在.vue文件中引入了 element-ui 的 table 和 pagination 组件后,报错:Component template should contain exactly one roo ...

  9. Do not use built-in or reserved HTML elements as component id:mask vue报错

    今天学习了一下vue的组件,但是报了一个错误 Do not use built-in or reserved HTML elements as component id:mask , 经过查询得知是因 ...

  10. Vue报错之"[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead......"

    一.报错截图 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the p ...

随机推荐

  1. SpringBoot整合Redis实现常用功能

    SpringBoot整合Redis实现常用功能 建议大小伙们,在写业务的时候,提前画好流程图,思路会清晰很多. 文末有解决缓存穿透和击穿的通用工具类. 1 登陆功能 我想,登陆功能是每个项目必备的功能 ...

  2. LOJ6077「2017 山东一轮集训 Day7」逆序对 (生成函数+多项式exp?朴素DP!)

    题面 给定 n , k n,k n,k ,求长度为 n n n 逆序对个数为 k k k 的排列个数,对 1 e 9 + 7 \rm1e9+7 1e9+7 取模. 1 ≤ n , k ≤ 100   ...

  3. 字符串KMP——用途广泛的字符串匹配算法 + 扩展KMP——特殊定义的字符串匹配

    引 入 引入 引入 " SY 和 WYX 在看毛片.(几 毛 钱买到的动作 片,毛 片) WYX 突然想回味一个片段,但是只记得台词里面有一句挺长的 " ∗ ∗ ∗ ∗ **** ...

  4. 第一章 kubernetes概述

    一.Kubernetes概述 1.官网地址:https://kubernetes.io 2.GuiHub:https://github.com/kubernetes/kubernetes 3.又来:谷 ...

  5. 项目管理构建工具——Maven(基础篇)

    项目管理构建工具--Maven(基础篇) 在前面的内容中我们学习了JDBC并且接触到了jar包概念 在后面我们的实际开发中会接触到很多jar包,jar包的导入需要到互联网上进行就会导致操作繁琐 Mav ...

  6. ELK接收paloalto防火墙威胁日志并定位城市展示

    ELK接收paloalto防火墙威胁日志并定位城市展示 一.准备环境: 搭建好的ELK环境 palo alto防火墙(企业用的) 二.安装logstash并做好过滤 将palo alto日志打到一台c ...

  7. C语言可以在执行语句中间定义变量吗?

    C语言可以在执行语句中间定义变量吗? 例如:for(int i=0; i<5; i++){                                                     ...

  8. 【疑难杂症】奇异值分解(SVD)原理与在降维中的应用

    前言 在项目实战的特征工程中遇到了采用SVD进行降维,具体SVD是什么,怎么用,原理是什么都没有细说,因此特开一篇,记录下SVD的学习笔记 参考:刘建平老师博客 https://www.cnblogs ...

  9. 创建一个 autocomplete 输入系统 - 前端 + 后端

    文章转载自:https://mp.weixin.qq.com/s/uqchdrkhdFsof0ZFtECujg 我们经常在网站搜索输入时,会帮我们提醒自动完成的功能,比如: 图片 当我们在百度上搜索 ...

  10. Elasticsearch: Cerebro 用户界面介绍