当前位置:网站首页>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的使用场景
边栏推荐
猜你喜欢

数据湖(二):什么是Hudi

汉源高科千兆12光12电管理型工业以太网交换机 12千兆光12千兆电口宽温环网交换机

Data Lake (3): Hudi Concept Terminology

Technology sharing | Description of the electronic fence function in the integrated dispatching system

Distributed current limiting, hand & redisson implementation

js stopwatch countdown plugin

php字符串的截取方式

To eliminate air bubbles to save the mushroom h5 small game source code

ETL(二):表达式组件的使用

MyCat2 introduction and installation and basic use
随机推荐
Js scratchable latex style draw plug-in
Chapter 11 Documents
SQL Server 2014安装教程(保姆级图解教程)
机器人碰撞检测方法形式化
simulink PID auto-tuning
PGSQL database to realize the import and export
分布式限流利器,手撕&redisson实现
package.json and package-lock.json
路由-嵌套路由
如何更好评估信用贷风险?看这场评分卡模型直播就可以了
Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
智能图像分析-智能家用电器图像目标检测统计计数检测与识别-艾科瑞特科技(iCREDIT)
To eliminate air bubbles to save the mushroom h5 small game source code
SQL Server修改数据
如何关闭开启硬件加速[通俗易懂]
智能手表前景如何?
There are several ways to jump to js source code, jump on the current page, jump on the blank page
图论之Prim,最小生成树该怎么解?
吾爱第三课-修改版权和资源
FreeRTOS--Priority Experiment