巷子
巷子
  • 发布:2023-05-10 16:58
  • 更新:2023-05-10 17:49
  • 阅读:547

plus.globalEvent.addEventListener,plus.globalEvent.removeEventListener

分类:Native.js

创建后
plus.globalEvent.addEventListener('pause', this.xxx);
plus.globalEvent.addEventListener('resume', this.xxx);


plus.globalEvent.removeEventListener('pause', this.xxx);
plus.globalEvent.removeEventListener('resume', this.xxx);

会导致页面上生命周期 onShow,onHide无法触发(从后台切换到前台,从前台切换到后)

但是从上一个页面返回会触发

2023-05-10 16:58 负责人:DCloud_App_Array 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

  • 巷子 (作者)

    感谢大哥回复,确实是你说的这样,文档上没用公开,但是打印出来有,如果整个不能调,有没有其他办法呢?

    2023-05-10 18:06

  • DCloud_App_Array

    回复 巷子: 应该使用app或页面的生命周期事件,什么情况下要用到plus.globalEvent.addEventListener?

    2023-05-26 19:51

  • 1***@qq.com

    回复 DCloud_App_Array: 有移除事件的方案吗,确实用到了。

    2023-09-13 14:18

  • 爱tutu爱生活

    回复 DCloud_App_Array: 重复进这个页面的时候,原来第一次都有这个事件了,如果不移除断的话,不就又新建一个一样的监听了。

    2024-04-15 10:34

要回复问题请先登录注册