<web-view src='{{src}}'></web-view>
src: `https://XXXXXX,
/*** 生命周期函数--监听页面加载
*/
onLoad(options) {this.srcFun(options)
},
srcFun(options){//当有子页面id时 更改内嵌页链接if (options.urlPathNew) { let url=`https://XXX/caseOrder?classicId=${options.urlPathNew}`this.setData({src:url})}
},
通过子页面特定的id有无进行判断,可根据项目自行修改
/*** 用户点击右上角分享*/onShareAppMessage(options) {const h5Url = options.webViewUrl; //当前页面h5的链接// 使用正则表达式提取 classicId 的值const matchResult = h5Url.match(/classicId=(\d+)/); // 判断是否匹配成功let srcPath='/pages/caseH5/case'if (matchResult && matchResult.length > 1) {let classicIdValue = matchResult[1];srcPath=`/pages/caseH5/case?urlPathNew=${classicIdValue}`} else {console.log("未找到 classicId");}return{title: "分享成功", //分享的标题path: srcPath, //分享的路径imageUrl:'/assets/share.png' //分享的封面图片}}