当前位置:网站首页>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}) } })
边栏推荐
- Nacos集群的搭建过程详解
- The 25 best free games on mobile in 2020
- Media query, rem mobile terminal adaptation
- Teach you simple steps to achieve industrial raspberries pie properly installed RS232 USB drive
- LaTeX image captioning text column automatic line wrapping
- cs231n learning record
- Quick Start to Drools Rule Engine (1)
- D45_Camera assembly Camera
- LaTeX uses frame to make PPT pictures without labels
- Tips for formatting code indentation
猜你喜欢
随机推荐
ev加密视频转换成MP4格式,亲测可用
指针常量与常量指针 巧记
格式化代码缩进的小技巧
系统基础-学习笔记(一些命令记录)
Q 2020, the latest senior interview Laya soul, do you know?
NACOS Configuration Center Settings Profile
设置文本向两边居中展示
txt文件英语单词词频统计
Network Protocol Fundamentals - Study Notes
The cocos interview answers you are looking for are all here!
Next-Generation Parsing Technology - Cloud Parsing
数组&的运算
LaTeX笔记
无法导入torchvision.io.read_image
盒子模型大详解
Error correction notes for the book Image Processing, Analysis and Machine Vision
uniapp打包次数限制怎么办?只需两步就能解决
NB-IOT智能云家具项目系列实站
Cocos Creator Mini Game Case "Stick Soldier"
Matplotlib绘图笔记









