美文网首页
uni-app 自定义顶部导航栏、web-view中获取网页标题

uni-app 自定义顶部导航栏、web-view中获取网页标题

作者: 不忘初心_d | 来源:发表于2025-02-16 14:27 被阅读0次
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参数 - 简书

相关文章

网友评论

      本文标题:uni-app 自定义顶部导航栏、web-view中获取网页标题

      本文链接:https://www.haomeiwen.com/subject/qivdpjtx.html