问题描述
原生小程序使用 Taro 组件,props 为空
复现步骤
Taro 组件:
import Taro, { Component } from '@tarojs/taro'
export default class TestCompA extends Component {
componentDidMount() {
console.log("!!!!!!!!!!!!", this.props.title);
}
render() {
console.log("!!!!!!!2", this.props.title);
return <View>???: {this.props.title}</View>
}
}
{
"navigationBarTitleText": "Native 测试",
"usingComponents": {
"test-comp-b": "../../component/nativeCompB/nativeCompB",
"test-comp-a": "../../component/testCompA/testCompA"
}
}
<view>
<view class="hello">{{ hello }}</view>
<test-comp-a title="{{ hello }}"></test-comp-a>
</view>
期望行为
显示 props 传入的值
报错信息
!!!!!!!2 undefined
系统信息
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
1.3.0 的 props 是 taro 内部维护的。无法作为原生小程序组件使用
Hello~
您的问题楼上已经提供了解决方案,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。
如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。
Good luck and happy coding~
那在 1.3 里面混合的方案不完整,这个是比较现实的场景,希望支持。
1.3 的 props 系统是不可能改回来的,现在至少有 20 个 issue 在抱怨原生小程序 props 系统的诡异问题,新的 props 系统也是我们实现很多其它特性的基础。
你这个需求属于比较小众的行为,要等到 1.3 稳定了才会去考虑去做。