[improvement] Dialog: add stopLoading method (#757)

This commit is contained in:
Fyerl 2018-10-16 19:24:47 +08:00 committed by neverland
parent 7b19680726
commit 60fbdfaded
3 changed files with 18 additions and 8 deletions

View File

@ -117,6 +117,7 @@ Page({
| Dialog.setDefaultOptions | `options` | `void` | 修改默认配置,对所有 Dialog 生效 |
| Dialog.resetDefaultOptions | - | `void` | 重置默认配置,对所有 Dialog 生效 |
| Dialog.close | - | `void` | 关闭弹窗 |
| Dialog.stopLoading | - | `void` | 停止按钮的加载状态 |
### Options

View File

@ -22,6 +22,7 @@ interface Dialog {
alert?: (options: DialogOptions) => Promise<DialogAction>;
confirm?: (options: DialogOptions) => Promise<DialogAction>;
close?: () => void;
stopLoading?: () => void;
install?: () => void;
setDefaultOptions?: (options: DialogOptions) => void;
resetDefaultOptions?: () => void;
@ -84,6 +85,12 @@ Dialog.close = () => {
queue = [];
};
Dialog.stopLoading = () => {
queue.forEach(dialog => {
dialog.stopLoading();
});
};
Dialog.setDefaultOptions = options => {
Object.assign(Dialog.currentOptions, options);
};

View File

@ -44,14 +44,7 @@ VantComponent({
watch: {
show(show) {
if (!show) {
this.setData({
loading: {
confirm: false,
cancel: false
}
});
}
!show && this.stopLoading();
}
},
@ -84,6 +77,15 @@ VantComponent({
});
},
stopLoading() {
this.setData({
loading: {
confirm: false,
cancel: false
}
});
},
onClose(action) {
if (!this.data.asyncClose) {
this.close();