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