iview怎么通过点击事件来删除选中的表数据 5

 我来答
百度网友a7db40b8
2018-12-17
知道答主
回答量:17
采纳率:66%
帮助的人:2.5万
展开全部

可以使用table的render方法, 通过在column中定义一个按钮来实现点击获取选中的数据

<Table border :columns="columns7" :data="data6"></Table>
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) => { //params是你选中行的数据
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: { //使用监听方法监听click事件,实现删除当前行
                                        click: () => {   
                                         this.remove(params.index)
                                        }
                                    }
                                }, 'Delete')
                            ]);
                        }
                    }
                ],
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式