[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.setDefaultOptions | `options` | `void` | 修改默认配置,对所有 Dialog 生效 |
| Dialog.resetDefaultOptions | - | `void` | 重置默认配置,对所有 Dialog 生效 | | Dialog.resetDefaultOptions | - | `void` | 重置默认配置,对所有 Dialog 生效 |
| Dialog.close | - | `void` | 关闭弹窗 | | Dialog.close | - | `void` | 关闭弹窗 |
| Dialog.stopLoading | - | `void` | 停止按钮的加载状态 |
### Options ### Options

View File

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

View File

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