实现功能:webview向h5页面传值
代码:
index.wxml
<web-view src="{{url}}"></web-view>
index.js
onLoad: function() {
let that = this;
let openId = wx.getStorageSync('openId');
that.setData({
url: '地址/index.html?id=' + openId
})
},
index.html
var id=window.location.href.split("=")[1];//从小程序webview链接上获取id
思路:通过url带参数的方式,h5页面去取参数
如果是带多个参数,可通过&符号去分别取