uni-app 自定义顶部导航栏、web-view中获取网页标题
2025-02-16 本文已影响0人
不忘初心_d
onReady() {
// #ifdef APP-PLUS
const pages = getCurrentPages()
const page = pages[pages.length - 1];
const currentWebview = page.$getAppWebview();
currentWebview.children()[0].addEventListener('titleUpdate', ({
title
}) => {
uni.setNavigationBarTitle({
title,
});
});
//更多设置查看文章末尾链接
currentWebview.setStyle({
titleNView: {
autoBackButton: true,
buttons: [{
float: 'right',
type: 'close',
onclick: () => {
uni.navigateBack();
}
}]
}
});
// #endif
},