<web-view src='{{src}}'></web-view>
src: `https://XXXXXX,
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad(options) {
this.srcFun(options)
},
srcFun(options){
//當有子頁面id時 更改內(nèi)嵌頁鏈接
if (options.urlPathNew) {
let url=`https://XXX/caseOrder?classicId=${options.urlPathNew}`
this.setData({
src:url
})
}
},
通過子頁面特定的id有無進行判斷,可根據(jù)項目自行修改文章來源地址http://www.zghlxwxcb.cn/news/detail-816606.html
/**
* 用戶點擊右上角分享
*/
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' //分享的封面圖片
}
}
文章來源:http://www.zghlxwxcb.cn/news/detail-816606.html
到了這里,關于微信小程序內(nèi)嵌h5 分享子頁面點擊進入后是主頁面解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!