wx.offBeforePageLoad(function listener)

基础库 3.5.5 开始支持,低版本需做兼容处理。

微信小程序插件:支持,需要微信小程序基础库版本不低于 3.5.5

微信 鸿蒙 OS 版:支持

功能描述

移除路由事件的监听函数

参数

function listener

onBeforePageLoad 传入的监听函数。不传此参数则移除所有监听函数。

示例代码

const listener = function (res) { console.log(res) }

wx.onBeforePageLoad(listener)
wx.offBeforePageLoad(listener) // 需传入与监听时同一个的函数对象