HarmonyOS uiContext.getPromptAction().openCustomDialog 能实现打开一个页面级的弹窗吗

uiContext.getPromptAction().openCustomDialog 能实现打开一个页面级的弹窗?或者有什么方式可以实现在页面内打开一个页面级别的弹窗吗?场景是在A页面内打开一个弹窗,弹窗中点击按钮打开新的B页面,在新的B页面中没有弹窗,但是进行返回到A页面时,已经打开的弹窗还在

HarmonyOS
2024-12-18 15:29:14
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

目前没有组件能直接实现这种效果,可以模拟弹窗效果来实现:参考demo如下:

import router from '@ohos.router';

@Entry
@Component
struct Index {
  @State textValue: string = 'Hello World'
  @State visible: Visibility = Visibility.None

  build() {
    Stack() {
      Row() {
        Column() {
          Text('Hello World')
            .fontSize(50)
            .fontWeight(FontWeight.Bold)
          Button('click')
            .onClick(() => {
              console.log("hit me!")
              if (this.visible == Visibility.Visible) {
                this.visible = Visibility.None
              } else {
                this.visible = Visibility.Visible
              }
            })
            .backgroundColor(0x777474)
            .fontColor(0x000000)
        }
        .width('100%')
      }
      .height('100%')
      .backgroundColor("#36D")
      Column() {
        GridRow({
          columns:{xs:1 ,sm: 4, md: 8, lg: 12},
          breakpoints: { value: ["400vp", "600vp", "800vp"],
            reference: BreakpointsReference.WindowSize },
        })
        {
          GridCol({
            span:{xs:1 ,sm: 2, md: 4, lg: 8},
            offset:{xs:0 ,sm: 1, md: 2, lg: 2}
          })
         }
       }
  • 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.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
分享
微博
QQ
微信
回复
2024-12-18 18:33:37
相关问题
如何新开一个半透明页面
769浏览 • 1回复 待解决
如何实现一个带动画弹窗
1275浏览 • 1回复 待解决
ArkTS如何实现一个底部弹窗
1764浏览 • 1回复 待解决