当前位置:网站首页>h5页面回退到微信小程序并携带参数
h5页面回退到微信小程序并携带参数
2022-08-05 05:29:00 【weixin_43923808】
背景:微信小程序通过web-view跳转到h5页面,操作后需要携带参数回到小程序。
用到的知识点:wx.miniProgram.postMessage
在h5页面:
-
wx.miniProgram.navigateBack({delta: 1}) wx.miniProgram.postMessage({data:{ billvId: String(this.billInfo.billvId)} })需要注意两点:1、一定要先navigateBack回退,然后再执行 postMessage的数据传输,因为官方文档中强调(网页向小程序 postMessage 时,会在特定时机(小程序后退、组件销毁、分享)触发并收到消息)
2、我们要传输的数据一定要放在data中
在小程序内的Web-view页面:
接收到传递的数据后,在获取当前页面栈,向前一个页面栈setData我们要传输的数据。
// 小程序代码 <web-view bindmessage="handleGetMessage" src="test.html"></web-view> Page({ handleGetMessage: function(e) { var pages = getCurrentPages(); var prevPage = pages[pages.length - 2]; let billvId = e.detail.data[0].billvId prevPage.setData({ invoiceId: billvId}) } })
边栏推荐
猜你喜欢
随机推荐
Alibaba Cloud Video on Demand
scikit-image image processing notes
云计算基础-学习笔记
cs231n学习记录
【内推】新相微电子
NACOS配置中心设置配置文件
Configuration of routers and static routes
The use of three parameters of ref, out, and Params in Unity3D
VLAN is introduced with the experiment
NB-IOT智能云家具项目系列实站
MyCat安装
多用户商城多商户B2B2C拼团砍价秒杀支持小程序H5+APP全开源
深入分析若依数据权限@datascope (注解+AOP+动态sql拼接) 【循序渐进,附分析过程】
网络协议基础-学习笔记
config.js相关配置汇总
In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]
unity 将Text批量替换为TextMeshProUGUI
After docker is deployed, mysql cannot connect
document.querySelector() method
【FAQ】什么是 Canon CCAPI








