我的場景的父組件吸頂樣式,拿到數(shù)據(jù)for each循環(huán)創(chuàng)建子組件:
private childRef = new ChildController();
@State childListRef: ChildController[] = []
拿到數(shù)據(jù)時:
//給子組件做響應(yīng)式賦值
for (let index = 0; index < this.infoTypeItemList.length; index++) {
this.childListRef.push(new ChildController());
}
//默認展示第一個
this.childRef = this.childListRef[0];
然后對子組件的賦值:
controller: this.childListRef[index]
然后調(diào)用子組件方法依然是:
this.childRef.refreshData()
【鴻蒙HarmonyOS】ArkTS父組件調(diào)用子組件方法使用場景:頁面包含吸頂結(jié)構(gòu)時,父組件刷新時需要調(diào)用子組件的請求方法 子組件創(chuàng)建一個ChildController 子組件聲明controller屬性 子組件添加方法 子組件在...