当前位置:网站首页>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);
},
边栏推荐
- [Prometheus] An optimization record of the Prometheus federation [continued]
- Delay queue optimization (2)
- DM8: Single database and single instance to build a local data guard service
- NXP IMX8QXP replacement DDR model operation process
- Two-point answer naked question (plus a little pigeonhole principle)
- C# wpf borderless window add shadow effect
- Common linked list problems and their Go implementation
- The Meta metaverse division lost 2.8 billion in the second quarter!Still want to keep betting?Metaverse development has yet to see a way out!
- 6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?
- OneFlow源码解析:Op、Kernel与解释器
猜你喜欢
随机推荐
终端分屏工具Terminalx的使用
Vulkan开启特征(feature)的正确姿势
Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
LeetCode 练习——关于查找数组元素之和的两道题
Chapter 14 Type Information
架构师如何成长
【Qt Designer工具的使用】
JS提升:Promise中reject与then之间的关系
requet.getHeader("token") is null
Go system collection
开心的聚餐
node封装一个控制台进度条插件
你好,我的新名字叫“铜锁/Tongsuo”
DM8: Single database and single instance to build a local data guard service
Hello, my new name is "Bronze Lock/Tongsuo"
线性筛求积性函数
golang日志库zerolog使用记录
【科普】无线电波怎样传送信息?
VS Code 连接SQL Server
VBA 运行时错误‘-2147217900(80040e14):自动化(Automation)错误









