Error message:The forEach method cannot be bound, 调用的对象是ArrayList
export class LUBCUAAgreementInfo {
id?: number
type?: string
}
export class LUBCUAUnifyAuthSceneInfoResult {
id?: number
sceneCode?: string
agreementInfoDTOS?: ArrayList<LUBCUAAgreementInfo>
}
调用代码
@Component
export struct LUBCUALoginView {
@Prop agreementData?: LUBCUAUnifyAuthSceneInfoResult
aboutToAppear(): void {
this.agreementData?.agreementInfoDTOS?.forEach((value: LUBCUAAgreementInfo, index: number) => {
})
}
}
ArrayList是jsapi中的一个类。数组是基础数据结构。两者从本质来说不是同一个类型。将ArrayList换成Array就不会报错了。
@Prop中建议使用Array,其中允许使用的类型可以参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-prop-V5