1、iview table 中操作按钮用到modal,想要改变modal实现两个单选,并根据选择传不同的值给后台
代码:
<Table
border
ref="selection"
:columns="tableColumns"
:data="tableData"
></Table>
data:{
radioValue: "",
tableColumns: [
{
title: "标签名称",
key: "labelName"
},
{
title: "操作",
fixed: "right",
width: 200,
align: "center",
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "error",
size: "small"
},
style: {
marginRight: "5px",
display:
params.row.state != "已删除" ? "inline-block" : "none"
},
on: {
click: () => {
this.$Modal.confirm({
title: "确认删除",
render: h => {
return h(
"RadioGroup",
{
props: {
value: this.radioValue
},
on: {
"on-change": val => {
this.radioValue = val;
}
}
},
[
h(
"Radio",
{
props: {
label: "1"
},
style: {
marginRight: "5px"
}
},
"仅删除标签"
),
h(
"Radio",
{
props: {
label: "3"
},
style: {
marginRight: "5px"
}
},
" 删除标签并删除关联关系"
)
]
);
},
onOk: () => {
this.delAction(params.row.labelId);
}
});
}
}
},
"删除"
)
]);
}
}
],
},
methods:{
delAction(id) {
}
2、render函数渲染的单选框,第一次选择这一项,第二次出现的时候还会默认选中这一项,期待做成第一次选中之后第二次默认清空
在这一行( click: () => { )下面加一句this.radioValue=’'就可以了