鸿蒙 文字右侧的小红点

鸿蒙 文字右侧的小红点

javascript 复制代码
@Entry
@Component
struct TestPage {
  // 每个页面自己控制条件
  @State showDot1: boolean = true;
  @State showDot2: boolean = false;

  build() {
    Column({ space: 30 }) {

      Stack({ alignContent: Alignment.TopEnd }) {
        Text("消息")
          .fontSize(44)
          .padding(6)
        // .alignSelf(ItemAlign.Start) // 关键:文字靠左,红点才能在右上角
        Badge1({show:true})

      }
      Stack({ alignContent: Alignment.TopEnd }) {
        Text("多擦第三次撒")
          .fontSize(44)
          .padding(6)
        // .alignSelf(ItemAlign.Start) // 关键:文字靠左,红点才能在右上角
        Badge1({show:true})
      }
    }
    .width('100%')
    .padding(30)
  }
}

@Component
export struct Badge1 {
  // 控制是否显示红点
  @Prop show: boolean = false;
  build() {
    if (this.show) {// 你的条件
      Circle()
        .width(15)
        .height(15)
        .fill(Color.Red)
        .margin({ top: 0, right: -5 })
    }
  }
}
相关推荐
ChinaDragonDreamer9 天前
HarmonyOS:知识点总结(一)
harmonyos·鸿蒙
加农炮手Jinx9 天前
Flutter for OpenHarmony 实战:JWT — 构建安全的无状态认证中心
网络·flutter·华为·harmonyos·鸿蒙
雷帝木木9 天前
Flutter for OpenHarmony:Flutter 三方库 money2 — 坚不可摧的鸿蒙金融核心组件
网络·flutter·http·华为·金融·harmonyos·鸿蒙
特立独行的猫a10 天前
uniapp-x的HarmonyOS鸿蒙应用开发:tabbar底部导航栏的实现
华为·uni-app·harmonyos·鸿蒙·uniapp-x
●VON10 天前
HarmonyOS应用开发实战(基础篇)Day10 -《鸿蒙网络请求实战》
网络·学习·华为·harmonyos·鸿蒙·von
●VON11 天前
HarmonyOS应用开发实战(基础篇)Day08-《构建布局详解上》
华为·harmonyos·鸿蒙·von
加农炮手Jinx13 天前
Flutter for OpenHarmony 实战:疯狂头像 App(三)— 复合动画与交互反馈 — 让 UI 跃动起来
flutter·ui·交互·harmonyos·鸿蒙
_waylau14 天前
鸿蒙架构师修炼之道-架构师设计思维特点
华为·架构·架构师·harmonyos·鸿蒙·鸿蒙系统
Betelgeuse7614 天前
【Flutter For OpenHarmony】 项目结项复盘
华为·交互·开源软件·鸿蒙
ITUnicorn15 天前
【HarmonyOS 6】进度组件实战:打造精美的数据可视化
华为·harmonyos·arkts·鸿蒙·harmonyos6