//定义类
class Item{
image:ResourceStr
constructor(image:ResourceStr){
this.image=image
}
}
@Entry
@Component
struct Index {
//声明变量
private items:Array<Item>=[
new Item($r('app.media.my_icon')),
new Item($r('app.media.my_icon')),
new Item($r('app.media.my_icon')),
new Item($r('app.media.my_icon')),
]
@State imageWidth:number=250
build() {
Column(){
Text('my_icon')
ForEach(
this.items,
(item:Item)=>{
Row({space:10}){
Image(item.image)
.width(100)
}
}
)
}
}
}