当前位置:网站首页>微信小程序内部A页面向内嵌H5页面跳转,并且传参
微信小程序内部A页面向内嵌H5页面跳转,并且传参
2022-08-11 00:10:00 【小任睡不醒`】
小程序中A页面代码JS代码
Page({
toPtol(e){
const id=e.currentTarget.dataset['id'];
const loadId=e.currentTarget.dataset['loadid'];
console.log(loadId)
wx.navigateTo({
url: '/pages/protocol/index?money=32132&loadId='+loadId
})
},
})
小程序中内嵌H5容器页面index.wxml
<web-view src="{
{url}}"></web-view>
小程序中内嵌H5容器页面index.js
Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
this.setData({
url:'https://www.zhiyunyi.net/protocol.html?money='+options.mone+'&loadId='+options.loadId+''
})
},
}
远程H5页面获取参数JS代码
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)")
var r = window.location.search.substr(1).match(reg)
if (r != null) return unescape(r[2])
return null
}
var loadId =getUrlParam('loadId')
console.log(loadId)
2.H5页面向小程序传参
内嵌H5JS代码
1.首先引入
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
2.添加跳转到小程序页面的代码,参数直接拼接
wx.miniProgram.reLaunch({ url: '/pages/index/index?name=张三&age=11'});
小程序内部页面代码index.js
Page({
onLoad: function (options) {
//options 就是H5传入的参数
}
3.内嵌H5页面的调试
1.首先引入
<script type="text/javascript" src="https://wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.3.0"></script>
2.JS中添加如下代码
window.vConsole = new window.VConsole();
3.再需要的地方打印console.log就可以了,这个方法特别适用远程web页面在手机端调试问题
边栏推荐
猜你喜欢
11. Custom Converter
How to recover deleted files from the recycle bin, two methods of recovering files from the recycle bin
宝塔实测-搭建PHP在线模拟考试系统
【openpyxl】过滤和排序
盘点美军的无人机家底
YOLOv5的Tricks | 【Trick11】在线模型训练可视化工具wandb(Weights & Biases)
什么是“门”电路(电子硬件)
15. Interceptor - HandlerInterceptor
Software Testing Certificate (1) - Software Evaluator
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
随机推荐
Qt入门(六)——抽奖系统的实现
【经典排序】快速排序
12. 处理 JSON
Lens filter---about day and night dual-pass filter
[21-day learning challenge - kernel notes] (5) - devmem read and write register debugging
Go项目配置管理神器之viper使用详解
SQL injection base
从0开始设计JVM ,忘记名词跟上思路一次搞懂
什么是“门”电路(电子硬件)
Navicat 16-数据库工具
李彦宏拆墙交朋友,大厂“塑料友情”能否帮百度啃下硬骨头?
Introduction to Qt (6) - Implementation of the lottery system
分库分表ShardingSphere-JDBC笔记整理
【js】获取当前时间的前后n天或前后n个月(时分秒年月日都可)
Server Tips
【openpyxl】只读模式、只写模式
云原生-FRP内网穿透(详解)使用云服务器将内网集群服务暴露至公网(二)
全排列思路详解
In 22 years, the salary of programmers nationwide in January was released, only to know that there are so many with annual salary of more than 400,000?
ASIO4ALL是什么