#鸿蒙学习大百科#如何通过AlertDialog实现一个警告弹窗?

如何通过AlertDialog实现一个警告弹窗?

HarmonyOS
2024-10-26 09:53:33
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
天涯独一隅
@Entry
@Component
struct Index {
  build() {
    Column() {
      Button('two button dialog')
        .onClick(() => {
          AlertDialog.show(
            {
              title: 'title',
              subtitle: 'subtitle',
              message: 'text',
              autoCancel: true,
              alignment: DialogAlignment.Bottom,
              gridCount: 4,
              offset: { dx: 0, dy: -20 },
              primaryButton: {
                value: 'cancel',
                action: () => {
                  console.info('Callback when the first button is clicked')
                }
              },
              secondaryButton: {
                enabled: true,
                defaultFocus: true,
                style: DialogButtonStyle.HIGHLIGHT,
                value: 'ok',
                action: () => {
                  console.info('Callback when the second button is clicked')
                }
              }
            }
          )
        }).backgroundColor(0x317aff)
    }
    .width('100%')
  }
}
分享
微博
QQ
微信
回复
2024-10-26 17:39:01
相关问题