13518219792

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

创新互联百度小程序教程:swan.offPageNotFound

swan.offPageNotFound

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

解释: 取消监听小程序要打开的页面不存在事件。

方法参数

Function callback

callback 参数说明

小程序要打开的页面不存在事件的回调函数(swan.onPageNotFound 的回调方法引用);当不传参数时,取消该类全部监听事件。

示例

在开发者工具中打开

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

请使用百度APP扫码

图片示例

代码示例

 
 
 
  1. App({
  2. onLaunch() {
  3. swan.onPageNotFound(function(res) {
  4. console.log('onPageNotFound', res);
  5. swan.showModal({
  6. title: '',
  7. content: '找不到页面'
  8. });
  9. });
  10. },
  11. onShow() {
  12. // 在App onShow后约3秒取消事件监听(仅做功能示例,开发者可根据业务逻辑选择取消监听时机)
  13. setTimeout(() => {
  14. swan.offPageNotFound(function(res) {
  15. console.log('offPageNotFound', res);
  16. });
  17. swan.showModal({
  18. title: '',
  19. content: '此后将不再触发swan.onPageNotFound回调'
  20. });
  21. }, 3000)
  22. }
  23. });

分享题目:创新互联百度小程序教程:swan.offPageNotFound
URL链接:http://cdbrznjsb.com/article/cceihgj.html

其他资讯

让你的专属顾问为你服务