当前位置:网站首页>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}) } })
边栏推荐
- Error correction notes for the book Image Processing, Analysis and Machine Vision
- 获取预训练模型的网络输入尺寸
- sql server duplicate values are counted after
- 系统基础-学习笔记(一些命令记录)
- 超简单的白鹭egret项目添加图片详细教程
- NAT experiment
- Nacos配置服务的源码解析(全)
- One-arm routing experiment and three-layer switch experiment
- Mina disconnects and reconnects
- Email management Filter emails
猜你喜欢

花花省V5淘宝客APP源码无加密社交电商自营商城系统带抖音接口

BIO, NIO, AIO practical study notes (easy to understand theory)

Collision, character controller, Cloth components (cloth), joints in the Unity physics engine

系统基础-学习笔记(一些命令记录)

BIO,NIO,AIO实践学习笔记(便于理解理论)

MyCat配置文件

七夕!专属于程序员的浪漫表白

深夜小酌,50道经典SQL题,真香~
D45_Camera assembly Camera

export使用
随机推荐
LeetCode刷题记录(2)
D45_Camera assembly Camera
Difference between link and @improt
【8】Docker中部署Redis
LeetCode中常用语言的一些基本方法记录
numpy.random usage documentation
格式化代码缩进的小技巧
VLAN is introduced with the experiment
Collision, character controller, Cloth components (cloth), joints in the Unity physics engine
MyCat安装
滚动条问题,未解决
Native JS takes you to understand the implementation and use of array methods
ES2020新特性
sql server duplicate values are counted after
获取预训练模型的网络输入尺寸
文件内音频的时长统计并生成csv文件
设置文本向两边居中展示
Tencent Internal Technology: Evolution of Server Architecture of "The Legend of Xuanyuan"
input detailed file upload
LaTeX image captioning text column automatic line wrapping