哈哈柚
哈哈柚
  • 发布:2022-02-13 22:01
  • 更新:2022-04-02 11:31
  • 阅读:1372

vue3 组合式api中如何使用eventChannel 向上个页面发送消息

分类:uni-app

如题,因为没有this,所以文档中的代码不好用

// #ifdef APP-NVUE  
  const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE  
  // #endif  
  // #ifndef APP-NVUE  
  const eventChannel = this.getOpenerEventChannel();  
  // #endif

虽然uni.$on和uni.$emit,但是作为全局监听,需要处理uni.$off,觉得还是有一定的潜在风险。
所以还是更习惯用navigateTo中的events

2022-02-13 22:01 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

这个解决了吗

  • 哈哈柚 (作者)

    没有,使用uni.$on了

    2022-03-15 09:59

  • 2***@qq.com

    回复 k***@makeitbetter.cn: 在vue3上面目前好像还是用不了

    2022-03-16 10:48

  • 哈哈柚 (作者)

    回复 2***@qq.com: 可以的,我是vue3的项目

    2022-03-25 09:25

  • 7***@qq.com

    回复 哈哈柚: 怎么用的

    2023-06-16 16:13

s***@qq.com
  • 哈哈柚 (作者)

    getCurrentInstance不建议使用,还是选择uni.$on,onUnload进行卸载

    2022-04-02 14:17

该问题目前已经被锁定, 无法添加新回复