小程序跳转H5
<view class="page-body">
<web-view src="https://xxx.com/test.html"></web-view>
</view>
H5跳转小程序
<!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>
小程序接收参数的页面
<view class="page-body">
{{phone}}
</view>
Page({
data: {
phone:''
},
onLoad: function (options) {
var that = this;
/*获取参数*/
var phone = options.phone
that.setData({
phone: phone,
})
}
})
官方调用案例
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
// javascript
wx.miniProgram.navigateTo({url: '/path/to/page'})
wx.miniProgram.postMessage({data: 'foo'})
wx.miniProgram.postMessage({data: {foo: 'bar'}})
wx.miniProgram.getEnv(function (res) { console.log(res.miniprogram) })
小程序跳转小程序
1.关联小程序
2.注意微信基础库的版本,版本过低无法跳转;
wx.getSystemInfo({
success:(res)=>{
console.log(res.SDKVersion); //基础库版本
}
});