当使用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>
原文:https://www.cnblogs.com/jianghongyun/p/13410252.html