文章摘要:h5页面如何连接小程序 小程序可以链接h5吗
在h5页面中连接小程序的方法 1.首先,在小程序页面内嵌h5网页; <view class=" […]
在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,
})
}
})