swan.offPageNotFound
兼容处理。 解释: 取消监听小程序要打开的页面不存在事件。
方法参数
参数说明
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
// app.jsApp({ onLaunch() { swan.onPageNotFound(function(res) { console.log(res); swan.showModal({ title: '', content: '找不到页面,将跳转到首页' }); swan.navigateTo({ url: '/index/index' }); }); }, onShow() { // 在App onShow后约3秒取消事件监听(仅做功能示例,开发者可根据业务逻辑选择取消监听时机) setTimeout(() => { swan.offPageNotFound(); swan.showModal({ title: '', content: '此后将不再触发swan.onPageNotFound回调' }); }, 3000) }});
