站内搜索:
首页 >> 前端 >> 内容
在vue中使用v-for时,出现告警问题的解决办法

时间:2017/11/13 9:34:16

在项目中运行v-for代码段时,

<flexbox v-if="roleShow" style="padding:15px; box-sizing: border-box;">  
    <flexbox-item v-for="role in roles " >  
        <x-button mini :type="role.type" style="padding: 0 14px" @click.native="btnClick(role.action)">{{role.value}}</x-button>  
    </flexbox-item>  
</flexbox>  

出现告警:component lists rendered with v-for should have explicit keys. See 

解决方法:

在代码中绑定key值,可解决,如:

<flexbox v-if="roleShow" style="padding:15px; box-sizing: border-box;">  
    <flexbox-item v-for="(role,index) in roles " :key="index" >  
        <x-button mini :type="role.type" style="padding: 0 14px" @click.native="btnClick(role.action)">{{role.value}}</x-button>  
    </flexbox-item>  
</flexbox>  

  • 上一篇:在input里添加小图标的方法及代码教程
  • 下一篇:highChart connectNulls图文讲解
  • 返回顶部