Skip to content
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