创新互联百度小程序教程:swan.offPageNotFound
- swan.offPageNotFound
- 方法参数
- callback 参数说明
- 示例
- 图片示例
- 代码示例
- 方法参数
swan.offPageNotFound
基础库 3.60.2 开始支持,低版本需做兼容处理。
解释: 取消监听小程序要打开的页面不存在事件。
方法参数
Function callback
callback 参数说明
小程序要打开的页面不存在事件的回调函数(swan.onPageNotFound 的回调方法引用);当不传参数时,取消该类全部监听事件。
示例
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
扫码体验
代码示例
请使用百度APP扫码
图片示例
代码示例
- JS
App({onLaunch() {swan.onPageNotFound(function(res) {console.log('onPageNotFound', res);swan.showModal({title: '',content: '找不到页面'});});},onShow() {// 在App onShow后约3秒取消事件监听(仅做功能示例,开发者可根据业务逻辑选择取消监听时机)setTimeout(() => {swan.offPageNotFound(function(res) {console.log('offPageNotFound', res);});swan.showModal({title: '',content: '此后将不再触发swan.onPageNotFound回调'});}, 3000)}});
本文题目:创新互联百度小程序教程:swan.offPageNotFound
网站路径:http://www.jxjierui.cn/article/cceihgj.html


咨询
建站咨询

