Files
lucky_shop/pages_tool/vr/index.vue
ZF sun eab5a97ba5 feat(vr page): add custom nav bar and support page title param
1. 为APP-PLUS端的VR页面配置自定义导航栏样式
2. 从路由参数中获取并设置页面标题
2026-07-25 15:20:51 +08:00

58 lines
911 B
Vue

<template>
<view :style="themeColor" class="vr-page">
<web-view :src="src" class="vr-webview" @titleUpdate="updateNavbarTitle"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
src: '',
title: ''
};
},
onLoad(option) {
this.title = option?.title ?? '';
this.$api.sendRequest({
url: '/api/config/defaultvr',
success: res => {
if (res.code == 0) {
this.src = res.data.url;
this.title = res.data.title;
}
},
fail: res => {
}
});
},
onShow() {
this.updateNavbarTitle();
},
watch: {
title(newVal) {
this.updateNavbarTitle(newVal);
}
},
methods: {
updateNavbarTitle(newTitle) {
const title = newTitle ?? this.title;
uni.setNavigationBarTitle({title});
}
}
};
</script>
<style lang="scss">
.vr-page {
height: 100vh;
width: 100%;
background: #fff;
}
.vr-webview {
width: 100%;
height: 100%;
}
</style>