1.H5链接地址必须是https开头
2.微信公众平台-开发管理-业务域名配置 才能访问到H5地址
uni-app小程序代码如下:
<template>
<view>
<web-view :src="urlH5"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
urlH5: 'H5地址', //必须是https开头
}
},
onLoad(options) {
this.orderId = options.orderId
let token = uni.getStorageSync('token')
this.urlH5 = `${this.urlH5}?orderId=${this.orderId}&token=${token}`;
},
}
</script>
H5页面通过url接收数据
data() {
return {
token: '', //token
orderId:''
}
},
created(){
this.orderId = this.getQueryString("orderId")
this.token = this.getQueryString('token')
},
methods:{
getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURIComponent(r[2]); // 如果小程序那边值加密了,这边就需要进行解密 decodeURIComponent(r[2])
}
return null;
}
}