mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
parent
832a5d3711
commit
bc4adf3d2a
28
dist/toptips/index.js
vendored
28
dist/toptips/index.js
vendored
@ -1,11 +1,10 @@
|
||||
var timer = undefined;
|
||||
|
||||
module.exports = {
|
||||
showZanTopTips(content = '', options = {}) {
|
||||
let zanTopTips = this.data.zanTopTips || {};
|
||||
// 如果已经有一个计时器在了,就清理掉先
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = undefined;
|
||||
if (zanTopTips.timer) {
|
||||
clearTimeout(zanTopTips.timer);
|
||||
zanTopTips.timer = undefined;
|
||||
}
|
||||
|
||||
if (typeof options === 'number') {
|
||||
@ -19,21 +18,22 @@ module.exports = {
|
||||
duration: 3000
|
||||
}, options);
|
||||
|
||||
// 设置定时器,定时关闭topTips
|
||||
let timer = setTimeout(() => {
|
||||
this.setData({
|
||||
'zanTopTips.show': false,
|
||||
'zanTopTips.timer': undefined
|
||||
});
|
||||
}, options.duration);
|
||||
|
||||
// 展示出topTips
|
||||
this.setData({
|
||||
zanTopTips: {
|
||||
show: true,
|
||||
content,
|
||||
options
|
||||
options,
|
||||
timer
|
||||
}
|
||||
});
|
||||
|
||||
// 设置定时器,定时关闭topTips
|
||||
timer = setTimeout(() => {
|
||||
this.setData({
|
||||
'zanTopTips.show': false
|
||||
});
|
||||
timer = undefined;
|
||||
}, options.duration);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user