This commit is contained in:
梁灏 2019-06-05 09:26:44 +08:00
parent ceae82348b
commit ff71751caa

View file

@ -23,7 +23,8 @@ Modal.newInstance = properties => {
loading: false, loading: false,
buttonLoading: false, buttonLoading: false,
scrollable: false, scrollable: false,
closable: false closable: false,
closing: false // 关闭有动画,期间使用此属性避免重复点击
}), }),
render (h) { render (h) {
let footerVNodes = []; let footerVNodes = [];
@ -158,12 +159,14 @@ Modal.newInstance = properties => {
}, },
methods: { methods: {
cancel () { cancel () {
if (this.closing) return;
this.$children[0].visible = false; this.$children[0].visible = false;
this.buttonLoading = false; this.buttonLoading = false;
this.onCancel(); this.onCancel();
this.remove(); this.remove();
}, },
ok () { ok () {
if (this.closing) return;
if (this.loading) { if (this.loading) {
this.buttonLoading = true; this.buttonLoading = true;
} else { } else {
@ -173,7 +176,9 @@ Modal.newInstance = properties => {
this.onOk(); this.onOk();
}, },
remove () { remove () {
this.closing = true;
setTimeout(() => { setTimeout(() => {
this.closing = false;
this.destroy(); this.destroy();
}, 300); }, 300);
}, },
@ -270,4 +275,4 @@ Modal.newInstance = properties => {
}; };
}; };
export default Modal; export default Modal;