Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 百度小程序 -不 支持模版传递函数参数 同时在真机时 它把函数改成了空对象,将函数参数暂存到 data 中 #15923

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/taro-plugin-react/src/runtime/connect-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading