在h5頁面中連接小程序的方法
1.首先,在小程序頁面內嵌h5網頁;
<view class="page-body">
<web-view src="https://xxx.com/test.html"></web-view>
</view>
2.在h5網頁中引入json文件,并調用wx.miniProgram.navigateTo方法連接小程序;
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8">
<title>h5跳轉小程序</title>
</head>
<body>
<h3 align="center">正在跳轉到小程序...</h3>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script>
wx.miniProgram.navigateTo({url: '/index/index?phone=18012121212'})
</script>
</body>
</html>
3.最后,在小程序頁面接受h5頁面的參數,即可;
<view class="page-body">{{phone}}
</view>
index.json
Page({
data: {
phone:''
},
onLoad: function (options) {
var that = this;
/*獲取參數*/
var phone = options.phone
that.setData({
phone: phone,
})
}
})