feat: add dynamic navigation bar title support for webview and form pages
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
This commit is contained in:
@@ -40,6 +40,11 @@ export default {
|
||||
scroll: true,
|
||||
uniacid: 0,
|
||||
isFromMpWebView: false, // 是否是从微信小程序的WebView跳转过来的
|
||||
|
||||
// #ifdef H5
|
||||
title: '', // 查询参数传入的Title
|
||||
enableSetTitle: false, // 查询参数传入的是否可以强制设置Title
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -66,6 +71,11 @@ export default {
|
||||
|
||||
uni.setStorageSync('skipPrivacyCheck', true);
|
||||
|
||||
// #ifdef H5
|
||||
this.title = options?.title ?? '';
|
||||
this.enableSetTitle = Boolean(options?.enable_set_title);
|
||||
// #endif
|
||||
|
||||
this.uniacid = options.uniacid
|
||||
this.id = options.id || 0
|
||||
this.isFromMpWebView = options.from === 'mp-webview';
|
||||
@@ -109,8 +119,17 @@ export default {
|
||||
if (res.code == 0 && res.data) {
|
||||
this.detail = res.data
|
||||
console.log(`form data =>`, this.detail)
|
||||
|
||||
let formName = res.data?.form_name ?? '';
|
||||
|
||||
// #ifdef H5
|
||||
if (this.enableSetTitle) {
|
||||
formName = this.title;
|
||||
}
|
||||
// #endif
|
||||
|
||||
uni.setNavigationBarTitle({
|
||||
title: res.data.form_name
|
||||
title: formName
|
||||
})
|
||||
}
|
||||
this.$refs.loadingCover && this.$refs.loadingCover.hide()
|
||||
|
||||
Reference in New Issue
Block a user