表格中添加單選框,而且互斥javascript
首先帶data中定義 currentid : 0 ;表示默認不選中java
{ 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) }, },