// #ifdef APP-NVUE
const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
// #endif
// #ifndef APP-NVUE
const eventChannel = this.getOpenerEventChannel();
// #endif
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
eventChannel.on('acceptDataFromOpenerPage', async (data) => {
console.log("data", data)
}

- 发布:2022-06-22 17:34
- 更新:2022-06-22 21:01
- 阅读:1206
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win11
HBuilderX类型: Alpha
HBuilderX版本号: 3.4.13
浏览器平台: Chrome
浏览器版本: 100
项目创建方式: HBuilderX
示例代码:
操作步骤:
复制上面代码到vue3 nvue的js中
复制上面代码到vue3 nvue的js中
预期结果:
h5也能接收到参数
h5也能接收到参数
实际结果:
h5接收不到参数
h5接收不到参数
bug描述:
按照官方的方法,在vue3 nvue页面js中写
// #ifdef APP-NVUE
const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
// #endif
// #ifndef APP-NVUE
const eventChannel = this.getOpenerEventChannel();
// #endif
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
eventChannel.on('acceptDataFromOpenerPage', async (data) => {
console.log("data", data)
}
nvue编译到小程序能正常接受到参数
但是编译到h5会无法接受到参数
页面报错
[Violation]Added non-passive event listener to a scroll-blocking <某些> 事件. Consider marking event handler as 'passive' to make the page more responsive. See <URL>
vue.runtime.esm.js:9469 [Violation]Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
云开发接单 (作者)
编译到app会显示TypeError: Cannot read property 'eventChannel' of undefined
2022-06-22 23:20
7***@qq.com
还没解决吗,1年了。真的是服了,这么重要的api能出错
2023-09-03 09:52