在iview 当中使用 select选择,外置一个按钮可以批量操作select的值
使用table 的render嵌套时需要注意option的值设置label
{
title: "命名空间",
key: "nodeSpace",
minWidth: 120,
sortable: false,
render: (h, params) => {
return h('Select', {
props: {
value: params.row.nodeSpace,//绑定数据
transfer: true,//不受表格高度影响
},
on: {
'onChange': (event) => {
this.flashDiskData[params.index].nodeSpace = event;
this.flashDiskSelect[params.index].nodeSpace = event;
}
},
},
this.allNode.map(function (type) { //这个数组需要在data中定义,里面是一个个对象,每个对象里面应当包含value属性(因为要用到)
return h('Option', {
props: {
value: type.minerId,
label: type.minerId,
key: type.minerId
}
}, type);
})
)
}
},
批量设置值时更改绑定值会触发查找改变
watch: {
selectNode: function(newVal, oldVal) {
this.flashSelectList.forEach((v,i)=>{
this.flashSelectList[i].nodeSpace = newVal
this.flashDiskData.forEach((v1,i1)=>{
if(v.diskSerial == v1.diskSerial){
this.flashDiskData[i1].nodeSpace = newVal
v1._checked = true
return
}
})
})
console.log(this.flashSelectList)
}
}
不设置lable