当前位置:网站首页>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);
},
边栏推荐
- 又一家公司面试的内容
- 6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?
- C# wpf 无边框窗口添加阴影效果
- 防抖和节流有什么区别,分别用于什么场景?
- Swiper rotates pictures and plays background music
- 谷歌AlphaFold近日宣称预测出地球上几乎所有蛋白质结构
- 常见链表题及其 Go 实现
- requet.getHeader(“token“) 为null
- 终端分屏工具Terminalx的使用
- Tensorflow2.0 混淆矩阵与打印准确率不符
猜你喜欢

【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list

C# wpf borderless window add shadow effect

微信小程序云开发 | 城市信息管理

Read the "Language Model" in one article

深入浅出边缘云 | 3. 资源配置

运营 23 年,昔日“国内第一大电商网站”黄了...

JS提升:Promise中reject与then之间的关系

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

Recommendation | People who are kind to you, don't repay them by inviting them to eat

OneFlow源码解析:Op、Kernel与解释器
随机推荐
SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
Immersive experience iFLYTEK 2022 Consumer Expo "Official Designated Product"
ROS 环境使用第三方动态链接库(.so)文件
Scala学习:类和对象
电脑死机的时候,发生了什么?
谷歌AlphaFold近日宣称预测出地球上几乎所有蛋白质结构
C# wpf borderless window add shadow effect
跨域问题的解决方法
VBA批量将Excel数据导入Access数据库
深化校企合作 搭建技术技能人才成长“立交桥”
二分答案裸题(加一点鸽巢原理)
DM8:单库单实例搭建本地数据守护服务
NXP IMX8QXP更换DDR型号操作流程
Delay queue optimization (2)
Common linked list problems and their Go implementation
LeetCode Exercise - Two Questions About Finding Sum of Array Elements
【每日一道LeetCode】——191. 位1的个数
高精度加法
【剑指 Offe】剑指 Offer 17. 打印从1到最大的n位数
JsonUtil基于字符串操作josn