接触小程序不久,接手的小程序项目,都是已写好的,在原基础上新增或者优化
需求:一个小程序包含多个h5
点击某一个地方,
wx.navigateTo({
url: ‘/pages/allH5Pages/allH5Pages?title=’+‘这里面传参数title’,
})
1、建一个专门放h5的page包allH5Pages:
wxml:
<web-view src="{
{H5Url}}"></web-view>
2、js
Page({
data: {
Title: "给个默认的title",
H5Url: '' "
},
// 跳转到这个页面,加上title的参数,根据传参不同,src不同,自定义
onLoad: function (options) {
console.log("宽带的options")
console.log(options.title)
let url = "";
if(options.title == 'h5链接3'){
url = "h5链接3"
this.setData({
H5Url:url,
Title: options.title
});
wx.setNavigationBarTitle({
title: options.title // 设置顶部title内容
})
}
else if(options.title =