可以在 P-comfirmpopup 组件内部编写一个叫做确认删除操作的函数,并将它包括在 OnRemove 属性的委托中。示例代码如下:
<template>
<p-chip
:label="chip.label"
selected
@remove="confirmRemove"
/>
<p-comfirmpopup
ref="confirmPopup"
title="Confirm Delete"
message="Are you sure, you want to delete this chip?"
confirmButtonText="Delete"
@confirm="remove"
/>
</template>
<script>
export default {
name: 'MyComponent',
props: {
chip: Object
},
methods: {
confirmRemove() {
this.$refs.confirmPopup.show();
},
remove() {
this.$emit('remove', this.chip);
}
}
};
</script>