通过路径传递
小程序js
let app = getApp();
Page({
data: {
pageUrl: ''
},
onLoad(options) {
realId = options.id;
tokenId = app.globalData.token;
this.setData({
pageUrl: 'https://www.goldcontrol.cn/wxroot/APP/JKZL/jknt/line-simple.html?token=' + tokenId + '&realId=' + realId
})
}
})
h5js
<script>
function getUrlParam(name) {
//分割参数
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) {
return r[2];
}
return null; //返回参数值
}
var tokenId = getUrlParam("token");
var realId = getUrlParam("realId");
$("#container").attr("src","./canvas.html?token="+tokenId +"&realId="+realId);
</script>
网友评论