表格中添加单选框,并且互斥

iview Table表格单选框互斥-LMLPHP

首先带data中定义   currentid : 0 ;表示默认不选中

{
title: "名称",
key: "name",
render: (h, params) => {
// console.log(params,'----------------params------------------') //为data中的值
let id = params.row.id;
let defaultS = false;
// console.log(this.currentid)
if (this.currentid == id) {
defaultS = true;
} else {
defaultS = false
}
let self = this;
return h('Radio', {
props: {
value: defaultS //判断单选框状态
},
on: {
'on-change': () => {
self.currentid = id; //赋值单选框id。对比id判断状态 }
}
}, params.row.cname)
},
},

  

render中使用for循环 ,, jsx中只能写表单式,不能写多行语句用map映射

 render: (h, params) => {
let stat = (params.row.size/1024).toFixed(2);
let IPArr = params.row.diskSizes;
for(var i in IPArr){
(IPArr[i].capacityInKB/1024).toFixed(2);
};
console.log(IPArr)
return h("div", [
h(
"Tooltip",
{
props: {
transfer: true
}
},
[
stat,
IPArr.map(function (item,index) {
return h('div',{
slot: 'content',
style: {
whiteSpace: 'normal',
wordWrap: 'break-word'
}
}, [
h('p' , item.disk)
])
})
]
)
]);
}

  

05-11 18:19