mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-22 06:31:46 +08:00
[improvement] Dialog: add stopLoading method (#757)
This commit is contained in:
parent
7b19680726
commit
60fbdfaded
@ -117,6 +117,7 @@ Page({
|
||||
| Dialog.setDefaultOptions | `options` | `void` | 修改默认配置,对所有 Dialog 生效 |
|
||||
| Dialog.resetDefaultOptions | - | `void` | 重置默认配置,对所有 Dialog 生效 |
|
||||
| Dialog.close | - | `void` | 关闭弹窗 |
|
||||
| Dialog.stopLoading | - | `void` | 停止按钮的加载状态 |
|
||||
|
||||
### Options
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user