Modal add before-close prop

This commit is contained in:
梁灏 2021-09-07 10:32:04 +08:00
parent ce92e4add3
commit 95bf1bfae9
2 changed files with 34 additions and 2 deletions

View file

@ -150,7 +150,8 @@
zIndex: {
type: Number,
default: 1000
}
},
beforeClose: Function
},
data () {
return {
@ -259,6 +260,21 @@
},
methods: {
close () {
if (!this.beforeClose) {
return this.handleClose();
}
const before = this.beforeClose();
if (before && before.then) {
before.then(() => {
this.handleClose();
});
} else {
this.handleClose();
}
},
handleClose () {
this.visible = false;
this.$emit('input', false);
this.$emit('on-cancel');