当前位置:网站首页>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的使用场景
边栏推荐
猜你喜欢
Object.entries()
用位运算为你的程序加速
Openlayers 快速上手教程
FreeRTOS--优先级实验
Technology sharing | Description of the electronic fence function in the integrated dispatching system
FreeRTOS experiment--one function creates multiple tasks
js true 3d histogram plugin
simulink PID auto-tuning
OpenFeign设置header的3种方式
Object.entries()
随机推荐
Custom mvc framework review
MFC入门教程(深入浅出MFC)
自定义mvc框架复习
定了!2022世界VR产业大会将继续在南昌召开
Pod调度策略:亲和性、污点与污点容忍
Intelligent Image Analysis-Intelligent Home Appliance Image Target Detection Statistical Counting Detection and Recognition-iCREDIT
网络流详解(流网图一般能够反映什么信息)
FreeRTOS实验--一个函数创建多个任务
There are several ways to jump to js source code, jump on the current page, jump on the blank page
智能图像分析-智能家用电器图像目标检测统计计数检测与识别-艾科瑞特科技(iCREDIT)
Technology sharing | Description of the electronic fence function in the integrated dispatching system
SQL Server 2014安装教程(保姆级图解教程)
js源码跳转的几种方式,在当前页面跳转,在空白页跳转
Four seasons of trees realized by svg
Js scratchable latex style draw plug-in
新特性解读 | MySQL 8.0 GIPK 不可见主键
ssm access database data error
svg实现的树木四季变化
【The 6th Strong Net Cup CTF-Wp】
MyCat2 introduction and installation and basic use