HarmonyOS 如何实现vue中v-if的写法

这些文字的切换从接口取state值来判断, ArkUI如何实现vue中v-if="state1" v-else-if="state2"这样的写法呢

HarmonyOS
2025-01-09 16:50:20
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

请参考以下示例:

@Entry
@Component
struct ActionSheetExample {
  @State billStatus:number = 1
  @State billStatusDesc:string = ''
  aboutToAppear(): void {
    if (this.billStatus == 0){
      this.billStatusDesc = '等待支付'
    }else  if(this.billStatus == 0){
      this.billStatusDesc ='待预约'
    }else {
      this.billStatusDesc ='待体检'
    }
  }
  build() {
    Column(){
      //实现方式1
      Row(){
        if (this.billStatus == 0){
          Text('等待支付')
        }else  if(this.billStatus == 0){
          Text('待预约')
        }else {
          Text('待体检')
        }
      }
      Divider().width('100%')
        .height(2)
        .backgroundColor(Color.Orange)
      //实现方式2
      Row(){
        Text(this.billStatusDesc)
      }

    }
  }
}
  • 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.
分享
微博
QQ
微信
回复
2025-01-09 19:59:37
相关问题
在ArkTs实现vueslot思路
1155浏览 • 1回复 待解决
HarmonyOS httpRequest,caPath路径写法
684浏览 • 1回复 待解决
HarmonyOS 关于$$.this写法
696浏览 • 1回复 待解决
HarmonyOS 接口回调写法
940浏览 • 1回复 待解决
HarmonyOS 状态绑定写法
677浏览 • 1回复 待解决
HarmonyOS 咨询一下Tab一些写法
934浏览 • 1回复 待解决
HarmonyOS 空值判断符写法
891浏览 • 2回复 待解决
HarmonyOS 多线程写法限制
846浏览 • 1回复 待解决
HarmonyOS V2和V1明显区别?
1518浏览 • 1回复 待解决