zoukankan      html  css  js  c++  java
  • Cannot use v-for on stateful component root element because it renders multiple elements.

    <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

    不考虑业务场景,一味的争执技术的高下,都是耍流氓。
  • 相关阅读:
    Java 链表
    知识点归列
    HTML和CSS必须知道的重点难点问题
    函数表达式
    javascript原型链
    canvas成长树
    checkbox选中问题
    使用vue-cli脚手架自定义iview主题
    AI学习吧-Redis操作-事务、订阅
    AI学习吧-REDIS-常识
  • 原文地址:https://www.cnblogs.com/leoych/p/14906515.html
Copyright © 2011-2022 走看看