为了方便记录防止代码丢失特此记录
对话框超时默认选择固定选项
{
// 对话框超时默认选择
//
let a = undefined
let b = undefined
new Promise(function (resvole, reject) {
a = dialogs.build({
title: "请选择",
content: "",
positive: "选项A",
negative: "选项B"
}).on("positive", () => {
resvole()
alert("选项A");
}).on("negative", () => {
resvole()
alert("选项B");
}).on('cancel', function () {
alert('按错地方了,默认选项B')
resvole()
})
//创建定时器
b = setTimeout(function () {
reject()
}, 2000)
a.show()
}).then(function () {
//已选择,清空定时器
clearTimeout(b)
}).catch(function () {
alert("超时,默认选项B");
a.dismiss()
})
}