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
},
另外附上webview参数更多可设置属性相关文章:uniapp webview参数 - 简书
上一篇 下一篇

猜你喜欢

热点阅读