先看结果:
需求:
根据用户状态判断显示按钮是冻结还是解冻。
实现代码:
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
render: (h, params) => {
if(params.row.userinfo_status==1){
var text = '解冻';
var style={
background:'#2d8cf0',
border:'1px solid #2d8cf0'
}
}else{
text = '冻结';
style={
background:'#ed4014',
border:'1px solid #ed4014'
}
}
return h('div', [
h('Button',
{
props: {
type: 'error',
size: 'small'
},
style: style,
on: {
click: () => {
this.frozen(params.row.userinfo_id,params.index)
}
}
}, text)
]);
}
}