vue使用component遇到的问题
2017-06-26 09:53
495 查看
- 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.-我是先谢了一个模板,内容如下:
<script type="text/html" id="zlbId-list-item"> <divclass="zlb_list_img"> <imgsrc="images/zlb_profile_photo1.png"alt=""/> </div> <div class="zlb_list_title"> <p class="zlb_list_title_level"></p> <p class="zlb_list_title_date"></p> </div> <div class="zlb_list_detail"></div> </script>
组件的写法:
Vue.component('list-item', {props: ['level', 'date', 'price'],template: $('#zlbId-list-item').html()})
最后渲染的时候报错:
<ul class="zlb_list" id="zlbId-list"><list-item v-for="items in list" class="zlb_list_item" :key="items.id"></list-item></ul>
从网上查看资料,说的是组件模板只能有一个根元素:
模板改成:
<script type="text/html" id="zlbId-list-item"><divclass="zlb_list_detail">123456</div></script>
就渲染成功
相关文章推荐
- Vue中使用better-scroll所遇到的若干问题
- 使用Vue框架开发商城mall项目中所遇到的问题及技术点总结
- vue项目中使用echarts 遇到问题总结
- 在使用vue-router遇到的问题以及解决办法
- 在使用vue-cli中遇到的几个问题
- 前后端分离的j2ee的web项目,使用vue方式,即{{}}方式批量传入前端参数,遇到一个一个问题,页面上一开始有{{}},怎么处理?
- Vue使用中遇到问题汇总(三)
- vue 2.0中使用axios遇到问题的解决方法
- Vue使用中遇到问题汇总(二)
- 当使用Vue开发前端遇到的问题及解决办法汇总
- Vue使用vux-ui自定义表单验证遇到的问题及解决方法
- vue项目中使用echarts 遇到问题总结2
- 使用vue时遇到的问题总结
- 使用vue遇到的问题
- VueAwesomeSwiper在VUE中的使用以及遇到的一些问题
- vue中使用daterangepicker遇到的小问题
- 使用vue的v-for与v-if遇到的一个问题
- Vue系列:在vux的popup组件中使用百度地图遇到显示不全的问题
- vue.js使用vue-cli打包遇到的坑,问题