vue.js - vue + iView:table 组件中 render 怎么绑定click事件
本文介绍了vue.js - vue + iView:table 组件中 render 怎么绑定click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
columnsData: [
{
type: 'selection',
width: 60,
align: 'center'
},
{
title: '角色Id',
key: 'roleId'
},
{
title: '角色名称',
key: 'roleName'
},
{
title: '显示下级',
key: 'isVisible'
},
{
title: '创建时间',
key: 'createTime'
},
{
title: '操作',
key: 'action',
width: 120,
render: (h, params) => {
return h('div', [
h('Button', {
props: {
type: 'text',
size: 'small'
},
on: {
click: this.updateRole()
}
}, '编辑')
])
}
}
]
方法:
updateRole: function () {
console.log('修改角色')
}
提示错误:
[Vue warn]: Invalid handler for event "click": got undefined
解决方案
render: (h, params) => {
return h('div', [
h('Button', {
props: {
type: 'text',
size: 'small'
},
on: {
click: () => {
this.updateRole(params.index)
}
}
}, '编辑')
])
}
这篇关于vue.js - vue + iView:table 组件中 render 怎么绑定click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文