首页 > 其他 > 详细

vue学习问题总结(一)

时间:2017-11-28 19:34:15      阅读:409      评论:0      收藏:0      [点我收藏+]
  1. 使用comopontent组件报错
    错误信息:vue.js:491 [Vue warn]: Unknown custom element: <todo-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
    代码:
    <p>
       使用component组件<br>
       <todo-item></todo-item>
    </p>
    Vue.component(‘todo-item‘,{
        template:‘I am a component‘
    });

    解决办法:将vue的全局注册提取到body的上面,html中就可以引用了

  2. 仍然使用上面的js代码,会报出第二个错误
    错误信息:Component template requires a root element, rather than just text.
    解决办法:错误提示中说组件模版中需要一个根元素,而不是文本,将里面的tempate增加html标签即可,更改完的代码
    Vue.component(‘todo-item‘,{
        template:"<li>I am a component</li>"
    });

     

vue学习问题总结(一)

原文:http://www.cnblogs.com/blueskyli/p/7911391.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!