From a6189a5f9ebe0fa12433505e75a85dc21f9a2fae Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Thu, 28 May 2026 16:07:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(webview&form):=20=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8Fwebview=E8=B7=B3=E8=BD=AC=E5=9C=BA?= =?UTF-8?q?=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 给h5和小程序端webview页面分别处理src参数,小程序端添加from=mp-webview参数 2. 新增isFromMpWebView标识,从跳转参数判断是否来自小程序webview 3. 非小程序webview场景下才设置页面导航栏标题 --- pages_tool/form/formdata.vue | 14 ++++++++++---- pages_tool/webview/webview.vue | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pages_tool/form/formdata.vue b/pages_tool/form/formdata.vue index bc28779..ebf6622 100644 --- a/pages_tool/form/formdata.vue +++ b/pages_tool/form/formdata.vue @@ -38,7 +38,8 @@ export default { isRepeat: false, complete: false, scroll: true, - uniacid: 0 + uniacid: 0, + isFromMpWebView: false, // 是否是从微信小程序的WebView跳转过来的 } }, computed: { @@ -67,6 +68,7 @@ export default { this.uniacid = options.uniacid this.id = options.id || 0 + this.isFromMpWebView = options.from === 'mp-webview'; if (options.scene) { const scene = decodeURIComponent(options.scene) @@ -98,9 +100,13 @@ export default { if (res.code == 0 && res.data) { this.detail = res.data console.log(`form data =>`, this.detail) - uni.setNavigationBarTitle({ - title: res.data.form_name - }) + + // 非H5的情况下,设置标题 + if (!this.isFromMpWebView) { + uni.setNavigationBarTitle({ + title: res.data.form_name + }) + } } this.$refs.loadingCover && this.$refs.loadingCover.hide() }, diff --git a/pages_tool/webview/webview.vue b/pages_tool/webview/webview.vue index 36ad4d3..bd9f928 100644 --- a/pages_tool/webview/webview.vue +++ b/pages_tool/webview/webview.vue @@ -18,7 +18,13 @@ export default { }; }, onLoad(option) { + // #ifdef H5 this.src = decodeEntity(decodeURIComponent(option.src)); + // #endif + + // #ifndef H5 + this.src = decodeEntity(decodeURIComponent(`${option.src}&from=mp-webview`)); + // #endif }, methods: { navigateBack() {