页面生命周期函数的执行顺序是onLoad>onShow>onReady,其中只有onReady中才能获取到DOM节点。
一、onShow函数
每一次的页面切入都会触发onShow函数。
import {onShow} from "@dcloudio/uni-app";
onShow(()=>{...})

如果我点击"跳转页面1"再返回再点击"跳转页面1"再返回,那么一共会执行三次onshow
对比一下onLoad,同样的操作只触发了一次:
二、onHide函数
每一次的页面切出都会触发onHide函数,学习通后台检测切屏就使用的onHide函数。
import {onHide} from "@dcloudio/uni-app";
onHide(()=>{...})

如果我点击"跳转页面1"再返回再点击"跳转页面1"再返回,那么一共会执行两次onHide。
