当前位置:网站首页>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}) } })
边栏推荐
猜你喜欢

农场游戏果园系统+牧场养殖系统+广告联盟模式流量主游戏小程序APP V1

前置++和后置++的区别

Tencent Internal Technology: Evolution of Server Architecture of "The Legend of Xuanyuan"

系统基础-学习笔记(一些命令记录)
![In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]](/img/b5/03f55bb9058c08a48eae368233376c.png)
In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]

人人AI(吴恩达系列)

【MyCat简单介绍】

DevOps - Understanding Learning

The future of cloud gaming

Mina's long and short connections
随机推荐
ev加密视频转换成MP4格式,亲测可用
el-progress implements different colors of the progress bar
Difference between link and @improt
LeetCode中常用语言的一些基本方法记录
cs231n学习记录
Late night drinking, 50 classic SQL questions, really fragrant~
【考研结束第一天,过于空虚,想对自己进行总结一下】
Network Protocol Fundamentals - Study Notes
selenium learning
LaTeX笔记
Passing parameters in multiple threads
Error correction notes for the book Image Processing, Analysis and Machine Vision
D45_Camera assembly Camera
VLAN is introduced with the experiment
关于Antd的Affix突然不好用了,或者Window的scroll监听不好用了
## 简讲protobuf-从原理到使用
transport layer protocol
Browser Storage for H5
【FAQ】What is Canon CCAPI
VS Code私有服务器部署(私有化)