请教下,小程序在首页的需要获取app传递的用户信息,在onLoad里面监听app发送的事件,ios发送的事件名称‘LoginUserInfoEvent’,参数是对象
onLoad() {
uni.onNativeEventReceive((LoginUserInfoEvent, data) => {
console.log('接收到宿主App消息:' + LoginUserInfoEvent + data);
storage.setAccessToken(data.refreshToken);
storage.setRefreshToken(data.accessToken);
let userInfo = {}
userInfo.id = data.id
userInfo.nickName = data.nickname
this.nickname = data.nickname
storage.setUserInfo(userInfo);
storage.setHasLogin(true);
console.log(data.nickname, data.id, data.refreshToken, data.accessToken)
})
}
1***@163.com (作者)
我是放到App.vue里面的onLaunch接收,你试试
2021-11-17 19:12
鹅鹅鹅鹅
回复 1***@163.com: 看这个解决方案,https://ask.dcloud.net.cn/article/39591
2022-01-12 14:30