#鸿蒙学习大百科#如何实现子组件根据优先级在不同尺寸的设备进行显示和隐藏?

如何实现子组件根据优先级在不同尺寸的设备进行显示和隐藏?

HarmonyOS
2024-09-25 10:40:36
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
福娃泡泡
@Entry
@Component
struct Index {
 @State rate: number = 100;
  build() {
    Column() {
      Row() {
        Image($r("app.media.icon04"))
          .width(40)
          .height(40)
          .displayPriority(1)
        Image($r("app.media.icon02"))
          .width(40)
          .height(40)
          .displayPriority(2)
        Image($r("app.media.icon01"))
          .width(40)
          .height(40)
          .displayPriority(3)//数值越大优先级越高
        Image($r("app.media.icon03"))
          .width(40)
          .height(40)
          .displayPriority(2)
        Image($r("app.media.icon05"))
          .width(40)
          .height(40)
          .displayPriority(1)
      }.width(this.rate + "%")
      .justifyContent(FlexAlign.SpaceEvenly)

      Slider({value:100,min:0,max:100})
        .onChange((value: number) => {
          this.rate  =value;
      })
    }
    .justifyContent(FlexAlign.Center)
    .height('100%')
    .width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.

分享
微博
QQ
微信
回复
2024-09-25 15:38:51
相关问题