优化utils的toast
This commit is contained in:
parent
63d313ed2f
commit
2a85c906dd
|
@ -187,11 +187,24 @@ function toPage(url, options, type) {
|
|||
}
|
||||
}
|
||||
|
||||
let toastTimer;
|
||||
function toast(title, options) {
|
||||
uni.showToast({
|
||||
...{ title: title, icon: "none" },
|
||||
...options
|
||||
});
|
||||
if (typeof options === "undefined") {
|
||||
options = {};
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!options.duration) {
|
||||
options.duration = 1500;
|
||||
}
|
||||
uni.showToast({
|
||||
...{ title: title, icon: "none" },
|
||||
...options
|
||||
});
|
||||
clearTimeout(toastTimer);
|
||||
toastTimer = setTimeout(() => {
|
||||
resolve();
|
||||
}, options.duration);
|
||||
})
|
||||
}
|
||||
|
||||
function formatNumber(num, limit) {
|
||||
|
|
Loading…
Reference in New Issue