首页 > 其他 > 详细

Cannot use v-for on stateful component root element because it renders multiple elements.

时间:2021-06-20 15:03:05      阅读:23      评论:0      收藏:0      [点我收藏+]
<template name:trailerStars>
    <image v-for="yellow in yellowScore"
    src="../static/icos/star-yellow.png" class="star-ico">
    </image>
    <image v-for="gray in grayScore"
    src="../static/icos/star-gray.png" class="star-ico">
    </image>  
</template>

 

错误原因:

不能在根元素(root element)使用 v-for,因为v-for是个循环体呈现多个元素,v-for在根元素上导致无法渲染。

解决方案:

将元素包裹到另外的标签中:

 

<template name:trailerStars>
    <view>
        <image v-for="yellow in yellowScore"
        src="../static/icos/star-yellow.png" class="star-ico">
        </image>
        <image v-for="gray in grayScore"
        src="../static/icos/star-gray.png" class="star-ico">
        </image>
    </view>
    
</template>

 

参考链接:https://blog.csdn.net/hua_ban_yu/article/details/80256611

 

Cannot use v-for on stateful component root element because it renders multiple elements.

原文:https://www.cnblogs.com/leoych/p/14906515.html

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