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

Mina's long and short connections

sql server duplicate values are counted after

numpy.random使用文档

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

VS Code私有服务器部署(私有化)

The hook of the operation of the selenium module

DevOps process demo (practical record)
盒子模型小练习

Error correction notes for the book Image Processing, Analysis and Machine Vision

The 25 best free games on mobile in 2020
随机推荐
深入分析若依数据权限@datascope (注解+AOP+动态sql拼接) 【循序渐进,附分析过程】
LaTeX image captioning text column automatic line wrapping
深夜小酌,50道经典SQL题,真香~
多用户商城多商户B2B2C拼团砍价秒杀支持小程序H5+APP全开源
Pytorch分布式并行处理
D45_Camera assembly Camera
config.js相关配置汇总
## 简讲protobuf-从原理到使用
【FAQ】什么是 Canon CCAPI
The size of the screen adaptation
超简单的白鹭egret项目添加图片详细教程
LaTeX笔记
LeetCode practice and self-comprehension record (1)
关于Antd的Affix突然不好用了,或者Window的scroll监听不好用了
Nacos集群搭建
滚动条问题,未解决
H5开发调试-Fiddler手机抓包
Detailed explanation of the construction process of Nacos cluster
document.querySelector() method
In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]