vue报错[Vue warn]: Unknown custom element: – did you register the component correctly? For recursive components, make sure to provide the “name” option.的解决方法

在vue开发的时候,调用组件后有如下报错:

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

(found in <Root>)

这个报错是因为找不到 mycom1 这个组件导致的,对于新手来说,这是个坑,因为vue要求如果创建组件时使用驼峰命名,调用组件的时候需要将驼峰改为横线-写法。

也就是说你创建组件的时候这样写,命名为 myCom1:

var app = new Vue({
    el: '#app',
    components: {
        'myCom1': {
            template: '<h1>我是myCom1组件</h1>'
        }
    }
})

 

调用的时候得写成 <my-com1></my-com1> 才行

 

 

 

 

 

关于博主
骨灰级博客玩家
国内第一批90后网站站长/程序员
做过七年前端讲师
目前从事锦鲤观赏鱼电商行业
鱼贝贝锦鲤创始人
文章列表
1
夜 无眠
夜 无眠
2
你好,2019
你好,2019
3
神坑react-native之黄色警告Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
神坑react-native之黄色警告Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
4
做前端开发的估计都这么干过。哈哈哈哈哈
做前端开发的估计都这么干过。哈哈哈哈哈
5
MongoDB数据库控制台中执行db.shutdownServer( )无法关闭数据库服务,提示shutdown command only works with the admin database; try 'use admin'的解决方法
MongoDB数据库控制台中执行db.shutdownServer( )无法关闭数据库服务,提示shutdown command only works with the admin database; try 'use admin'的解决方法
最新评论
比比拉布
比比拉布
5月7日
太感谢了!!!!!!找了这么多的教程,只有你点出来了关键点——设计视图!!!!
Jake
Jake
3月7日
Halo 啊~麻烦更新下我的博客地址,原名:Jing Blog。麻烦更新如下: Jake Blog(后缀可以省略,也可以保留,看哪个风格适合) 网址:htt
评论于关于博主