在Vue2.0 使用v-for時報這樣的錯誤:component lists rendered with v-for should have explicit keys.解決方法:

在vue2.0+element-ui時的v-for  報了一個這樣錯誤:

(Emitted value instead of an instance of Error) <el-tag v-for="tag in getHasRoles(scope.row.superrole)">: component lists rendered with v-for should have explicit keys.


意思是在說,組件列表呈現v-for渲染時,應該有明確的keys。在前面你用到了v-for="(item,index) in data",但是你沒有明確:keys,且這個keys應該是唯一的。所以  在組件上 加上“:keys=‘index’”即可。希望可以幫到您。

<el-tag margin-right="5px" size="mini" v-for="(tag,index) in getHasRoles(scope.row.superrole)" :type="tag.summary" :key="index">

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章