rex ed834afc44
feat(Dialog): add new prop beforeClose (#3815)
* feat(dialog): add new prop beforeClose

* docs(dialog): update doc & example

fix #3769

* docs(dialog): fix component demo

fix #3812
2020-12-06 21:43:44 +08:00

80 lines
1.2 KiB
JavaScript

import Page from '../../common/page';
import Dialog from '../../dist/dialog/dialog';
const message = '代码是写出来给人看的,附带能在机器上运行';
Page({
data: {
show: false,
},
showCustomDialog() {
this.setData({ show: true });
},
getUserInfo(event) {
console.log(event.detail);
},
onClickThemeAlert() {
Dialog.alert({
title: '标题',
theme: 'round-button',
message,
});
},
onClickThemeAlert2() {
Dialog.alert({
theme: 'round-button',
message,
});
},
onClickAlert() {
Dialog.alert({
title: '标题',
message,
});
},
onClickAlert2() {
Dialog.alert({
message,
});
},
onClickConfirm() {
Dialog.confirm({
title: '标题',
message,
});
},
onClickAsyncClose() {
const beforeClose = (action) =>
new Promise((resolve) => {
setTimeout(() => {
if (action === 'confirm') {
resolve(true);
} else {
// 拦截取消操作
resolve(false);
}
}, 1000);
});
Dialog.confirm({
title: '标题',
message,
beforeClose,
});
},
onClose() {
this.setData({
show: false,
});
},
});