#跟着坚果学鸿蒙#在ArkTs中,如何在ForEach中,实现触摸事件的状态改变。onTouch((event: TouchEvent))
·
需要如何修改 @Builder bottom_img(item:bottom_img_text, index:number){ Column(){ if(4<index&&index<8) { if(index==6) { Image(item.bt_img_false) .width(100) .height(60) }else { Image(this.set_img_off? item.bt_img_true:item.bt_img_false) .width(30) .height(60) } }else { Image(this.set_img_off? item.bt_img_true:item.bt_img_false) .width(50) .height(60) .borderRadius({topLeft:10,topRight:10}) Text(item.bt_text) .fontSize(16) .fontColor(Color.White) .margin({top:-20}) } } .height('100%') .backgroundColor("#ff00172d") .onTouch((event: TouchEvent)=>{ if(this.off === index){ this.set_img_off = !this.set_img_off } }) } build() { Row(){ ForEach(this.bt_array_list,(item:bottom_img_text,index:number)=>{ this.bottom_img(item,index) }) } .width('100%') .height('100%') .justifyContent(FlexAlign.SpaceBetween) .padding({left:10,right:10,top:1}) } }
更多推荐
所有评论(0)