chore:微信小程序自定义标题已经可以开始展示了
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view :style="themeColor" class="vr-page">
|
||||
<web-view :src="src" class="vr-webview" @titleUpdate="updateNavbarTitle"></web-view>
|
||||
<web-view :src="src" class="vr-webview" @load="onWebViewLoad"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -27,17 +27,24 @@ export default {
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
this.updateNavbarTitle();
|
||||
if (this.title) {
|
||||
uni.setNavigationBarTitle({ title: this.title });
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
title(newVal) {
|
||||
this.updateNavbarTitle(newVal);
|
||||
if (newVal) {
|
||||
uni.setNavigationBarTitle({ title: newVal });
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateNavbarTitle(newTitle) {
|
||||
const title = newTitle ?? this.title;
|
||||
uni.setNavigationBarTitle({title});
|
||||
onWebViewLoad() {
|
||||
if (this.title) {
|
||||
setTimeout(() => {
|
||||
uni.setNavigationBarTitle({ title: this.title });
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user