IView table单选实现

IView table单选实现
步骤一:<Table ref=“modalTable”:columns=“modalColumns” :data=“testData” border stripe>
步骤二:
data() {
return {
currentChoose: ‘0’,
modalColumns: [
{
title: ‘选择’,
key: ‘id’,
width: 70,
align: ‘center’,
render: (h, params) => {
let id = params.row.id;
let flag = false;
if (this.currentChoose === id) {
flag = true
} else {
flag = false
}
let self = this
return h(‘div’, [
h(‘Radio’, {
props: {
value: flag
},
on: {
‘on-change’: () => {
self.currentChoose = id;
}
}
})
])
}
},
{title: ‘姓名’, key: ‘name’},
{title: ‘手机号’, key: ‘contactPhone’},
]
}}

注意:testData数据中要包含id字段且包含id值数值类型的数据

作者:carry_carrie
来源:CSDN
原文:https://blog.csdn.net/qq_35858002/article/details/88710244