当前位置:网站首页>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的使用场景
边栏推荐
- Taurus.MVC V3.0.3 Microservice Open Source Framework Released: Make the evolution of .NET architecture easier in large concurrency.
- js semi-circle loading progress animation js special effects
- Process finished with exit code 1
- 1.3快速生成树协议RSTP
- 用位运算为你的程序加速
- Four seasons of trees realized by svg
- An example of type3 voltage loop compensator taking Boost as an example
- ESP8266模块使用完整教程「建议收藏」
- Speed up your programs with bitwise operations
- js炫酷仪表盘插件
猜你喜欢
ETL(二):表达式组件的使用
How to better assess credit risk?Just watch this scorecard model live
LeetCode_139_单词拆分
photo-sphere-viewer Chinese documentation
Data Lake (2): What is Hudi
Intouch Historian历史曲线配置导入导出
js炫酷仪表盘插件
MyCat2的介绍与安装以及基本使用
An example of type3 voltage loop compensator taking Boost as an example
FreeRTOS experiment--one function creates multiple tasks
随机推荐
svg气球升起爆炸js特效
SQL Server database generation and execution of SQL scripts
基础协议讲解
pig4cloud服务架构使用
PGSQL database to realize the import and export
手撸架构,Mysql 面试126问
【第六届强网杯CTF-Wp】
【The 6th Strong Net Cup CTF-Wp】
LeetCode_377_组合总和Ⅳ
sql concat()函数
LeetCode_377_Combination Sum IV
A powerful js pop-up alert plugin
一款强大的js弹出alert插件
#Summer Challenge#[FFH] OpenHarmony Device Development Foundation (3) Compilation Dependencies
FreeRTOS--Priority Experiment
SQL Server 2014 installation tutorial (nanny-level graphic tutorial)
Openlayers Quick Start Tutorial
photo-sphere-viewer中文文档
Chapter 14 Manually create a REST service (2)
FreeRTOS创建任务--动态创建、静态创建