列表entry->src->main->module.json5
entry->src->main->module.json5
"requestPermissions": [ {"name": "ohos.permission.INTERNET"} ],
Index.ets
arrayList=[
{"name":"苹果","price":3.5,"imageUrl":"https://img1.baidu.com/it/u=1513650579,1757297287&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1681059600&t=2bdf979a877dd8723c72d7285b140734"},
{"name":"香蕉","price":5.5,"imageUrl":"https://img0.baidu.com/it/u=387808086,3839707072&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1681059600&t=eb4513cd82a1e087c2e5fbb6a887b376"},
]
build() {
Column(){
List(){
ForEach(this.arrayList,(item,index)=>{
ListItem(){
Row(){
Image(item.imageUrl)
.layoutWeight(1)
.height(200)
Text(item.name)
.fontSize(20)
.fontColor(Color.Red)
.margin({left:20})
Text(item.price+"/kg")
.fontSize(20)
.margin({left:20,right:20})
}
}
})
}
}
}