vue 动态添加表格列

this.currentMaxBatch++
let batch '批次' + this.currentMaxBatch // 新增的列名
// 添加数据
this.productDataSource.forEach(item => {
    console.log('item=', item)
    this.$set(item, batch, '') // v-model可实时更新
    // item[batch] = '' // v-model不能实时更新
})
// 添加列名
let columnsItem = {
    title: batch,
    width: 100,
    align: 'center',
    dataIndex: batch,
    scopedSlots: { customRender: batch },
}
this.$nextTick(() => {
    this.productColumns.push(columnsItem)
    // 需要渲染列的集合,用于template渲染列
    this.operation.push(batch)
})

 

posted @ 2020-09-15 11:06  梦里小屋  阅读(4890)  评论(0编辑  收藏  举报