HarmonyOS Span组件无法弹出Popup弹窗?

@Entry
@Component
struct Index {
  @State customPopup: boolean = false;

  // popup构造器定义弹框内容
  @Builder
  popupBuilder() {
    Column() {

    }
    .width(600)
    .height(372)
  }

  build() {
    Column() {
      Text() {
        Span('一昨丹阳王气销,尽将豪侈谢尘嚣。')
        Span('衣冠不复宗唐代,父老犹能道晋朝。')
          .bindPopup(this.customPopup, {
            builder: this.popupBuilder, // 气泡的内容
            placement:Placement.Bottom, // 气泡的弹出位置
            popupColor:Color.White, // 气泡的背景色
            radius: 10,
            arrowOffset: 20,
            mask: {color: '#80000000'},
            onStateChange: (e) => {
              console.info(JSON.stringify(e.isVisible))
              if (!e.isVisible) {
                this.customPopup = false
              }
            }
          })
          .fontColor(Color.Blue)
          .textBackgroundStyle({color: "#7F007DFF", radius: "5vp"})
        Span('万岁楼边谁唱月,千秋桥上自吹箫。')
        Span('青山不与兴亡事,只共垂杨伴海潮。')
      }
      Button('Span无法弹出Popup')
        .onClick(() => {
          this.customPopup = !this.customPopup
        })
        .margin({top: 100})
    }
    .height('100%')
    .width('100%')
    .justifyContent(FlexAlign.Center)
  }
}
阅读 417
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进