当前位置:网站首页>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);
},
边栏推荐
猜你喜欢
Hello, my new name is "Bronze Lock/Tongsuo"
【每日一道LeetCode】——191. 位1的个数
电脑死机的时候,发生了什么?
【剑指 Offe】剑指 Offer 18. 删除链表的节点
Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
Spark学习:用spark实现ETL
Swiper轮播图片并播放背景音乐
【Swords Offer】Swords Offer 17. Print n digits from 1 to the largest
6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?
随机推荐
ctf.show_web5
跨域问题的解决方法
架构师如何成长
Chapter 14 Type Information
中集世联达工业级成熟航运港口人工智能AI产品规模化应用,打造新一代高效能智慧港口和创新数字港口,全球港航人工智能能领军者中集飞瞳
Immersive experience iFLYTEK 2022 Consumer Expo "Official Designated Product"
Swiper轮播图片并播放背景音乐
【Qt Designer工具的使用】
【PHPWord】Quick Start of PHPWord in PHPOffice Suite
实体中增加操作方法
nlohmann json 使用指南【visual studio 2022】
[TypeScript]编译配置
"Ruffian Heng Embedded Bimonthly" Issue 59
Tensorflow2.0 混淆矩阵与打印准确率不符
深化校企合作 搭建技术技能人才成长“立交桥”
CIMC Shilian Dafeitong is the global industrial artificial intelligence AI leader, the world's top AI core technology, high generalization, high robustness, sparse sample continuous learning, industri
Fixed asset visualization intelligent management system
【Swords Offer】Swords Offer 17. Print n digits from 1 to the largest
Pytorch foundation -- tensorboard use (1)
2种手绘风格效果比较,你更喜欢哪一种呢?