uniapp定时器的使用

//uniapp中的具体用法:我这里使用到了setInterval
data() {
return {
timer: null//定时器名称
};
},
//一般在页面需要的地方使用,这里我是放在了onshow()里
onShow() {
// console.log('onshow');
this.timer = setInterval(function() {
// 放入你自己的业务逻辑代码
}, 3000);
},
//uniapp中onHide()能监听到页面离开
onHide() {//离开页面前清除计时器
// console.log('onHide');
clearInterval(this.timer);
this.timer = null;
},

 

 

uniapp

popup的@change使用

在触发方法后 会调用很多遍

if(!e.show){
  //当e.show为false时也会调用很多遍  导致性能不好
}

解决办法 加入另一个判断条件拦截

bleChange(e) {
if(!e.show && this.bleLoading){  //bleLoading控制按钮的:loading 属性
this.bleLoading = false
this.ble_scan_close()
}
},

 

posted @   On1on  阅读(635)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
点击右上角即可分享
微信分享提示