当前位置:网站首页>Entering the applet for the first time
Entering the applet for the first time
2022-07-30 19:02:00 【open the door of the world】
The first time to enter the applet judgment
背景需求
- Entering the applet for the first time,show bubbles.
- It disappeared after five seconds,After click event,The display of bubbles disappears
- 如果五秒内,点击了事件,The bubbles disappear
实现
- Enter the bubble for the first time,Show in five seconds,
- 设置一个变量,Controls the appearance of bubbles
- This time a variable is stored,Determine whether it is the first time to show
- 第一次进入,Locally stored variables,肯定是false,If the local variable isfalse ,Then change the bubble variable,为true
- And add a timer,五秒后,Change the local variable to true,and change the value of the bubble to false
- 如果是点击
- 先清空定时器,然后取反即可,and set the local variablefalse
- 注意点
This five-second timing,Is the request finished interface,有数据的时候,Only show bubbles.All this methods are placed after the interface
代码
- Judgment of first entry
bubbleFunc() {
// 气泡
let bubble = wx.getStorageSync('bubble');
if (!bubble) {
this.setData({
isShowBubble: true,
});
}
if (this.data.isShowBubble && this.data.numLikes) {
this.$data.timerID = setTimeout(() => {
this.setData({
isShowBubble: false,
});
clearInterval(this.$data.timerID);
}, 5000);
wx.setStorageSync('bubble', true);
}
},
- 点击逻辑
bubbleHandler() {
clearInterval(this.$data.timerID);
const {
isShowBubble } = this.data;
this.setData({
isShowBubble: !isShowBubble,
});
wx.setStorageSync('bubble', true);
},
边栏推荐
猜你喜欢

Pytorch基础--tensorboard使用(一)

【总结】1396- 60+个 VSCode 插件,打造好用的编辑器

LeetCode 练习——关于查找数组元素之和的两道题

深化校企合作 搭建技术技能人才成长“立交桥”

The use of @ symbol in MySql

经济新闻:错误# 15:初始化libiomp5md。dll,但发现libiomp5md。已经初始化dll。解决方法

LeetCode Exercise - Two Questions About Finding Sum of Array Elements

Meta元宇宙部门第二季度亏损28亿!仍要继续押注?元宇宙发展尚未看到出路!

Graphic LeetCode -- 11. Containers of most water (difficulty: medium)

延时队列优化 (2)
随机推荐
Go 系统收集
JsonUtil基于字符串操作josn
卫星电话是直接与卫星通信还是通过地面站?
C# wpf borderless window add shadow effect
牛客刷题系列之进阶版(搜索旋转排序数组,链表内指定区间反转)
架构师如何成长
跨进程启动后台服务
7.30模拟赛总结
VBA 运行时错误‘-2147217900(80040e14):自动化(Automation)错误
【Qt Designer工具的使用】
牛客刷题系列之进阶版(组队竞赛,排序子序列,倒置字符串, 删除公共字符,修理牧场)
启动前台Activity
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.解决方法
Delay queue optimization (2)
Basic use of scrapy
AWS console
Scala学习:breakable
nlohmann json 使用指南【visual studio 2022】
Recommendation | People who are kind to you, don't repay them by inviting them to eat
VS Code 连接SQL Server