前言:在項目中用到的表格插件中,在最后一欄的‘操作’中我設置了‘編輯’和‘刪除’按鈕,那么在選擇某條數據刪除的時候不僅要檢查是否選中,提示是否刪除還是很有必要的
1.沒加Poptip之前是這樣寫的:
{
title: '操作',
key: 'action',
width: 150,
align: 'center',
render: (h, params) => {
return h('div', [
h('Icon', {
class: 'deleteHover',
props: {
type: 'md-trash'
},
attrs: {
title: '刪除'
},
on: {
click: () => {
this.remove(params.row)
}
}
}, '刪除')
]);
}
}
2.加Poptip后這樣寫:
{
title: '操作',
key: 'action',
width: 150,
align: 'center',
render: (h, params) => {
return h('div', [
h('Poptip', {
props: {
placement: 'left-start',
confirm: true,
transfer: true,
title: '確定刪除嗎?',
},
on: {
'on-ok': () => {
this.remove(params)
},
'on-cancel': () => {
}
}
}, [
h('Icon', {
class: 'deleteHover',
props: {
type: 'md-trash'
},
attrs: {
title: '刪除'
},
style: {
cursor: 'pointer'
},
on: {
click: () => {
}
}
}, '刪除')
])
]);
}
}