首页 > 其他 > 详细

组件嵌套时报: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.

时间:2017-12-13 22:40:06      阅读:444      评论:0      收藏:0      [点我收藏+]

在组件嵌套的过程中,报了一个错误:

技术分享图片

这里报错的原因是:vue的组件(模板)只能有一个根节点,即.vue文件中的<template>标签下只能有一个子元素。

因此,建议大家在写.vue组件的时候,最好在<template>下添加一个标签(比如div),在这个标签里面写我们的组件。

例如:

1 <template>
2     <div>
3         <!--你的组件代码-->
4     </div>
5 </template>    

 

我这边就是用这种方法解决的。也希望能帮助到大家。

组件嵌套时报: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.

原文:http://www.cnblogs.com/toTo-li/p/8034327.html

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