当前位置:网站首页>uniapp/小程序 onload方法每次打开页面都执行解读
uniapp/小程序 onload方法每次打开页面都执行解读
2022-08-02 12:49:00 【哈尔滨洛弘科技有限公司】
最近做了一个程序发现我的onload方法居然每次加载页面都执行了,努力找了两三天问题,终于发现其中的奥妙了
onload是否执行是要看你的页面是卸载了还是隐藏了,只有卸载的页面才会执行onload,因为卸载代表页面的生命周期结束,下次进入的时候就进入一个新的生命周期了
那么什么时候算卸载,什么时候算隐藏呢?
比如A页面是程序的首页,我从A页面进入B页面,这时候是A和B两个页面都存在生命周期,当由B退回A,那么B的生命周期结束了,当你再从A进入B页面,相当于从新开了B的生命周期,所以每次从A打开B,都会执行onload,那么我又从B进入了C页面,这时候从C退回B,那么C得生命周期结束,B的页面显示,这时候就不会执行B的onload,那么我再打开C就会执行C的onload。
总结来看就是我这个页面如果是打开的就要每次都要执行onload,这个页面是退回的就不会执行onload
希望此次解析能让大家理解onload的使用场景
边栏推荐
猜你喜欢
随机推荐
Openlayers Quick Start Tutorial
FreeRTOS--stack experiment
Name conventions in FreeRTOS
Import and export data of SQL Server database
Seneor曝光基础知识
FreeRTOS--优先级实验
【第六届强网杯CTF-Wp】
MD5详解(校验文件完整性)
冰箱“扩容”的战事,在今夏格外猛烈
FreeRTOS--栈实验
unique in numpy & pandas
js stopwatch countdown plugin
企业用直播平台能实现什么
A powerful js pop-up alert plugin
不错的射击类js小游戏源码
Detailed explanation of network flow (what information can the flow network diagram generally reflect)
Intouch System Platform IDE-1
MD5 detailed explanation (check file integrity)
如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?
LeetCode_377_Combination Sum IV









