From 80c137ffbd466d8f52d8d697ce5af9c1643f03b5 Mon Sep 17 00:00:00 2001 From: tony chen Date: Tue, 4 Jun 2024 17:59:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BE=E5=BA=A6=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=20=E4=B8=8D=E6=94=AF=E6=8C=81=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E5=87=BD=E6=95=B0=E5=8F=82=E6=95=B0=20?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=9C=A8=E7=9C=9F=E6=9C=BA=E6=97=B6=20?= =?UTF-8?q?=E5=AE=83=E6=8A=8A=E5=87=BD=E6=95=B0=E6=94=B9=E6=88=90=E4=BA=86?= =?UTF-8?q?=E7=A9=BA=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/runtime/connect-native.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/taro-plugin-react/src/runtime/connect-native.ts b/packages/taro-plugin-react/src/runtime/connect-native.ts index e3f5a127329b..56270e2c91ba 100644 --- a/packages/taro-plugin-react/src/runtime/connect-native.ts +++ b/packages/taro-plugin-react/src/runtime/connect-native.ts @@ -368,11 +368,25 @@ export function createNativeComponentConfig (Component, react: typeof React, rea type: null, value: null, observer (_newVal, oldVal) { + if (process.env.TARO_ENV === 'swan') { + // 百度模版传递 props 时 函数参数会被忽略,这里需要根据 id 获取 TaroElement 中的 props 赋值到 ctx.data 中 + const inst: any = document.getElementById(this.id) + if (this.component?.ctx?.data && inst) { + this.component.ctx.data.props = inst?.props?.props + } + } oldVal && this.component?.forceUpdate() } } }, created () { + if (process.env.TARO_ENV === 'swan') { + const inst: any = document.getElementById(this.id) + // 百度小程序 真机上 props中的函数会被转为Object 调用报错 导致后续组件无法渲染 这里先取TaroElement上的props,在properties中会重新赋值 + if (this.data?.props && inst) { + this.data.props = inst.props?.props || {} + } + } const app = (isNewBlended ? nativeComponentApp : Current.app) if (!app) { initNativeComponentEntry({