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)
      }

    }
  }
}
分享
微博
QQ
微信
回复
2025-01-09 19:59:37
相关问题
在ArkTs实现vueslot思路
1394浏览 • 1回复 待解决
HarmonyOS httpRequest,caPath路径写法
879浏览 • 1回复 待解决
HarmonyOS 关于$$.this写法
854浏览 • 1回复 待解决
HarmonyOS 如何离线访问vue页面
689浏览 • 1回复 待解决
HarmonyOS 接口回调写法
1187浏览 • 1回复 待解决
HarmonyOS 咨询一下Tab一些写法
1161浏览 • 1回复 待解决
HarmonyOS 状态绑定写法
913浏览 • 1回复 待解决
HarmonyOS vue和ArkTS交互demo
1111浏览 • 1回复 待解决
HarmonyOS vue框架与ArkTS交互
1722浏览 • 1回复 待解决
HarmonyOS 真机如何获取v4、v6ip栈信息
1042浏览 • 1回复 待解决
HarmonyOS 空值判断符写法
1164浏览 • 1回复 待解决