iview table里的render的一些数据格式
{
title:'操作',
align: 'center',
width:120,
render:(h,params)=>{
return h('div',[
h('span', {
style:{
'margin-right':'10px',
'color':'#2d8cf0',
'cursor':'pointer'
},
on: {
click: () => {
this.edit(params.row.id)
}
}
},'编辑'),
h('span', {
style:{
'color':'#2d8cf0',
'cursor':'pointer'
},
on: {
click: () => {
this.delete(params.row.id,params.row.accountName)
}
}
},'删除')
])
}
Button
{
title: '操作',
align: 'center',
render:(h,params)=>{
return h('div',[
h('Button', {
props: {
type: 'primary',
},
style:{
'margin-right':'5px'
},
on: {
click: () => {
this.edit(params.row.id)
}
}
},'编辑'),
h('Button', {
props: {
type: 'primary',
},
on: {
click: () => {
this.delete(params.row.id)
}
}
},'删除')
])
}
}
switch
{
title: '状态',
width:60,
align: 'center',
render:(h,params)=>{
return h('div',[
h('i-switch', {
props: {
type: 'primary',
value: true //控制开关的打开或关闭状态,官网文档属性是value
},
style: {
//display: params.index !== 0 ? 'none' : 'inline'
},
on: {
'on-change': (value) => {//触发事件是on-change,用双引号括起来,
//参数value是回调值,并没有使用到
this.switch(params.index) //params.index是拿到table的行序列,可以取到对应的表格值
}
}
})
])
}
}
checkbox
{
title: '是否启用',
align: 'center',
width:200,
key:'flag',
render:(h,params)=>{
const row = params.row;
const flagVal = row.flag
return h('div',[
h('Checkbox', {
props: {
value: flagVal ,
},
on:{
'on-change': () =>{
alert(1);
}
}
})
])
}
},
对数据进行操作