mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-23 09:50:27 +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 = {
|
module.exports = {
|
||||||
showZanTopTips(content = '', options = {}) {
|
showZanTopTips(content = '', options = {}) {
|
||||||
|
let zanTopTips = this.data.zanTopTips || {};
|
||||||
// 如果已经有一个计时器在了,就清理掉先
|
// 如果已经有一个计时器在了,就清理掉先
|
||||||
if (timer) {
|
if (zanTopTips.timer) {
|
||||||
clearTimeout(timer);
|
clearTimeout(zanTopTips.timer);
|
||||||
timer = undefined;
|
zanTopTips.timer = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options === 'number') {
|
if (typeof options === 'number') {
|
||||||
@ -19,21 +18,22 @@ module.exports = {
|
|||||||
duration: 3000
|
duration: 3000
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
|
// 设置定时器,定时关闭topTips
|
||||||
|
let timer = setTimeout(() => {
|
||||||
|
this.setData({
|
||||||
|
'zanTopTips.show': false,
|
||||||
|
'zanTopTips.timer': undefined
|
||||||
|
});
|
||||||
|
}, options.duration);
|
||||||
|
|
||||||
// 展示出topTips
|
// 展示出topTips
|
||||||
this.setData({
|
this.setData({
|
||||||
zanTopTips: {
|
zanTopTips: {
|
||||||
show: true,
|
show: true,
|
||||||
content,
|
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