当前位置:网站首页>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}) } })
边栏推荐
- 滚动条问题,未解决
- Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
- vscode笔记
- cs231n learning record
- DevOps process demo (practical record)
- 深入分析若依数据权限@datascope (注解+AOP+动态sql拼接) 【循序渐进,附分析过程】
- Next-Generation Parsing Technology - Cloud Parsing
- 亚马逊美国站:马术头盔CPC认证标准要求
- 【FAQ】CCAPI兼容EOS相机列表(2022年8月 更新)
- 错误记录集锦(遇到则记下)
猜你喜欢
随机推荐
网络排错基础-学习笔记
lingo入门——河北省第三届研究生建模竞赛B题
MyCat配置文件
LaTeX 图片加标题 文本分栏自动换行
LaTeX使用frame制作PPT图片没有标号
vscode notes
如何将.asd恢复为Word文档
js 使用雪花id生成随机id
Matplotlib绘图笔记
DevOps流程demo(实操记录)
Browser Storage for H5
## 简讲protobuf-从原理到使用
Tencent Internal Technology: Evolution of Server Architecture of "The Legend of Xuanyuan"
系统基础-学习笔记(一些命令记录)
The size of the screen adaptation
Jenkins详细配置
【内推】新相微电子
The use of three parameters of ref, out, and Params in Unity3D
ev加密视频转换成MP4格式,亲测可用
【FAQ】What is Canon CCAPI