iview table 自定义列_iview表格自定义列模板

在使用iview的表格组件时,遇到点击delete或view按钮无反应,导致后台报错`this.remove is not a function`和`this.show is not a function`。问题出现在自定义列的渲染函数中,`show`和`remove`方法未正确绑定到Vue实例上。解决方案是确保在点击事件中使用`Vue.prototype.$Modal`和`this.data6.splice()`时,上下文指向正确,即使用`that.show`或`this.$parent.show`来调用方法。
摘要由CSDN通过智能技术生成

问题描述

点击delete或者view页面没反应,后台报错

vue.min.js:6 TypeError: this.remove is not a function

this.show is not a function

问题出现的环境背景及自己尝试过哪些方法

没办法~

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

var app=new Vue({

el:'#app',

data: {

columns7: [

{

title: 'Name',

key: 'name',

render: (h, params) => {

return h('div', [

h('Icon', {

props: {

type: 'person'

}

}),

h('strong', params.row.name)

]);

}

},

{

title: 'Age',

key: 'age'

},

{

title: 'Address',

key: 'address'

},

{

title: 'Action',

key: 'action',

width: 150,

align: 'center',

render: (h, params) => {

return h('div', [

h('Button', {

props: {

type: 'primary',

size: 'small'

},

style: {

marginRight: '5px'

},

on: {

click: () => {

this.show(params.index)

}

}

}, 'View'),

h('Button', {

props: {

type: 'error',

size: 'small'

},

on: {

click: () => {

this.remove(params.index)

}

}

}, 'Delete')

]);

}

}

],

data6: [

{

name: 'John Brown',

age: 18,

address: 'New York No. 1 Lake Park'

},

{

name: 'Jim Green',

age: 24,

address: 'London No. 1 Lake Park'

},

{

name: 'Joe Black',

age: 30,

address: 'Sydney No. 1 Lake Park'

},

{

name: 'Jon Snow',

age: 26,

address: 'Ottawa No. 2 Lake Park'

}

]

},

methods:{

show (index) {

this.$Modal.info({

title: 'User Info',

content: `Name:${this.data6[index].name}
Age:${this.data6[index].age}
Address:${this.data6[index].address}`

})

},

remove (index) {

this.data6.splice(index, 1);

}

}

})

你期待的结果是什么?实际看到的错误信息又是什么?

到底是哪里有问题啊,求帮助!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值