1. add title and enableSetTitle data fields for webview and form pages 2. implement auto set navigation bar title when enabled 3. add URL normalize and query params append utilities 4. pass title and enable_set_title params across pages and external links
60 lines
1.2 KiB
Vue
60 lines
1.2 KiB
Vue
<template>
|
||
<view :style="themeColor">
|
||
<view class="iconfont iconshang navigate-back" @click="navigateBack"></view>
|
||
<web-view :src="src"></web-view>
|
||
|
||
<!-- 隐私弹窗 -->
|
||
<privacy-popup ref="privacyPopup"></privacy-popup>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { decodeEntity } from '@/common/js/util.js';
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
src: '',
|
||
title: '', // 标题栏标题
|
||
enableSetTitle: false, // 是否强制设置标题,用来替换Webview中的默认标题
|
||
};
|
||
},
|
||
onLoad(option) {
|
||
this.title = option?.title ?? '';
|
||
this.enableSetTitle = Boolean(option?.enable_set_title);
|
||
|
||
// #ifdef H5
|
||
this.src = decodeEntity(decodeURIComponent(option.src));
|
||
// #endif
|
||
|
||
// #ifndef H5
|
||
this.src = decodeEntity(decodeURIComponent(`${option.src}&from=mp-webview`));
|
||
// #endif
|
||
},
|
||
onReady() {
|
||
if (this.enableSetTitle) {
|
||
uni.setNavigationBarTitle({
|
||
title: this.title
|
||
});
|
||
}
|
||
},
|
||
methods: {
|
||
navigateBack() {
|
||
uni.navigateBack({
|
||
delta: 1
|
||
});
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.navigate-back {
|
||
position: absolute;
|
||
top: 34rpx;
|
||
left: 34rpx;
|
||
z-index: 5;
|
||
font-size: $font-size-toolbar;
|
||
}
|
||
</style>
|