鸿蒙 文字右侧的小红点

鸿蒙 文字右侧的小红点

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 })
    }
  }
}
相关推荐
心中有国也有家2 天前
Flutter for OpenHarmony:Flutter 图像渲染核心Image 组件详解
开发语言·前端·flutter·华为·harmonyos·鸿蒙
加农炮手Jinx2 天前
Flutter for OpenHarmony 实战:built_collection 全链路不可变集合模型
网络·flutter·华为·harmonyos·鸿蒙
加农炮手Jinx2 天前
Flutter for OpenHarmony 实战:url_launcher 插件 — 跨应用跳转与系统集成
flutter·harmonyos·鸿蒙
●VON3 天前
HarmonyOS应用开发实战(基础篇)Day02-《ArkTS函数》
学习·harmonyos·鸿蒙·基础知识·von
加农炮手Jinx3 天前
Flutter for OpenHarmony 实战:sensors_plus 传感器融合与 3D 体感交互
网络·flutter·3d·华为·交互·harmonyos·鸿蒙
儿歌八万首3 天前
鸿蒙 ArkUI 实战:打造 AI 对话流式打字机效果
鸿蒙·自定义组件·arkui·im布局
_waylau3 天前
跟老卫学仓颉编程语言开发:整数类型
算法·华为·harmonyos·鸿蒙·鸿蒙系统·仓颉
加农炮手Jinx3 天前
Flutter for OpenHarmony 实战:Riverpod 2.0 响应式架构与大规模状态治理
网络·flutter·华为·架构·harmonyos·鸿蒙
加农炮手Jinx3 天前
Flutter for OpenHarmony 实战:flutter_rust_bridge 跨语言高性能计算深度解析
开发语言·flutter·rust·harmonyos·鸿蒙