需求:点击A页面的
跳转网页
按钮跳转到B页面,B页面使用web-view
组件(用于展示H5),并向H5传递参数,H5弹框要显示这些参数。
image.png
做法:
image.png
- index.js
jumpWeb(){
wx.navigateTo({
url: '../webView/webView?type=' + '1' + "&orderId=" + '6666'
})
}
image.png
- webView.js
onLoad: function (options) {
this.setData({
webSrc:'http://extend.feiyang.life/#/login?type=' + options.type + "&orderId=" + options.orderId
})
},
- webView.wxml
<web-view src='{{webSrc}}'></web-view>
image.png
(vue项目)
- Login.vue
mounted() {
// 获取浏览器的参数并弹框
var type = this.$route.query.type;
var orderId = this.$route.query.orderId;
var toastMsg = 'type为 ' + type + ' orderId为 ' + orderId;
this.$fyToast(toastMsg);
},