@Preview
@Component
export struct ContentItemView {
private itemInfo: ContentListItemInfo
constructor(itemInfo: ContentListItemInfo) {
super()
this.itemInfo = itemInfo
}
build() {
}
}
class ContentListItemInfo {
在上述代码中,itemInfo会报错,因为没有初始化。
我的目的是,写一个布局,通过Info的参数进行数据配置。那么这个 itemInfo理论上会传递进来,要怎么改?
private 私有变量不能接受外部传进来的参数,传进来的参数需要通过prop去接收。
请参考示例: