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)
})

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM