vue動態渲染表格表頭和列表等,視圖不更新,視圖錯亂問題


當使用for循環動態渲染表頭時,表格視圖不更新。經檢查發現,key值原先綁定的是索引,即 :key="i",導致 item.prop改變后視圖更新錯亂,key值更改后  :key="item.prop",問題得到解決

<template v-for="(item, i) in tableColumn">
   <vxe-table-column width="160" :key="item.prop" v-if="i === 0" :field="item.prop" :title="item.desc"></vxe-table-column>
   <vxe-table-column :key="item.prop" v-else :field="item.prop" :title="item.desc"></vxe-table-column>
</template>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM