uni.navigateTo({
url: '/pageShop/detail',
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('getShopDetail', {
data: 'test'
})
}
})
const eventChannel = this.getOpenerEventChannel()
eventChannel.on('getShopDetail', e => {
const {
data
} = e
console.log(data);
})
- 发布:2023-07-08 16:46
- 更新:2023-07-10 09:47
- 阅读:306
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 21H2
HBuilderX类型: 正式
HBuilderX版本号: 3.8.7
手机系统: Android
手机系统版本号: Android 10
手机厂商: 小米
手机机型: 小米8
页面类型: vue
vue版本: vue3
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
A页面
uni.navigateTo({
url: '/pageShop/detail',
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('getShopDetail', {
data: 'test'
})
}
})
B页面
onLoad() {
const eventChannel = this.getOpenerEventChannel()
eventChannel.on('getShopDetail', e => {
const {
data
} = e
console.log(data);
})
}
A页面
uni.navigateTo({
url: '/pageShop/detail',
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('getShopDetail', {
data: 'test'
})
}
})
B页面
onLoad() {
const eventChannel = this.getOpenerEventChannel()
eventChannel.on('getShopDetail', e => {
const {
data
} = e
console.log(data);
})
}
预期结果:
可以正常触发on事件
可以正常触发on事件
实际结果:
没有触发on事件,没有打印出日志
没有触发on事件,没有打印出日志
bug描述:
eventChannel 在App中 被打开页面,没有触发on事件
piaoyi_UI - 【插件开发】【专治疑难杂症】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=193663(微信搜索飘逸科技UI小程序直接体验)】【骗子请绕道】问题咨询请加QQ群:120594820,代表作灵感实用工具小程序
这个去年测试过,小程序可以,在app端不会触发,现在已经可以了吗
b***@163.com (作者)
这是文档地址:
https://uniapp.dcloud.net.cn/api/router.html#navigateto
这个说明很明显了,是可以这么用的
2023-07-08 23:03