did you register the component correctly? For recursive components, make sure to provide the “name“

vue引用组件 did you register the component correctly? For recursive components, make sure to provide the “name”
阐述问题:
  • 在项目中用到了vue引用外部组件,报以上错误,百度了好半天,发现跟自己的问题还是不符合。下面说下我的问题所在。
错误信息及错误截图
  • 通过以下错误可以看到,大概的意思就是:正确注册组件了吗?对于递归组件,请确保提供“name”选项。
  • 其实我的这个问题不在子组件,折腾了半天,更换子组件名,更换子组件大小写,检查components是否正确。最后都是正确的。问题出在了Home,父组件里面。
[Vue warn]: Unknown custom element: <aaa> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Home> at src/views/home/Home.vue
       <App> at src/App.vue
         <Root>

在这里插入图片描述

解决以上错误:
  • 问题出现在了home.vue里面,是我自己不小心,多写了一段 script,也就是有两个name,有两个script,所以会报 错误信息及错误截图 中的问题。删除了多余的就解决了。

父组件代码:Home.vue

<template>
  <div>
 
    <div>
      <aaa name="aaa"></aaa>
    </div>
      <div class="box5">
        <div>
          <text class="title-detial">基因序列:s4s5hidcskjkskhf90h</text>
        </div>
        <div class="jiyin">
          <image class="jiyin" src="/static/images/image/temp/11.png"></image>
        </div>
      </div>
    </div>
    <div class="s-box">
      <div class="box3">
        <div>
          <image class="return" src="/static/images/image/public/return.png"></image>
        </div>
        <div class="Title">区块链溯源</div>
      </div>
      <div class="suyuan-detial">
        <text>2020-07-21</text>
        <text>食品药品监督管理同己同步</text>
        <text>2020-05-13</text>
        <text>肉质检中心已同步</text>
      </div>
    </div>
  </div>
</template>
<script>
  import WinNavbar from "components/common/winNavbar/WinNavbar";
  import aaa from "../../components/common/aaa/aaa";
  export default {
    components: {
      aaa,
    },

  }
</script>
<style scoped>

</style>
<script>
export default {
  name: "Home",
}
</script>

子组件代码:aaa.vue

<template>
  <div class="aaa">
    222222222222
  </div>
</template>

<script>
export default {
  name: "aaa"
}
</script>

<style scoped>

</style>

最后提醒搬砖的小伙伴们,在写代码的时候一定要仔细哦!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值