HarmonyOS 半屏时间弹窗

是否有如图半屏的时间弹窗?

HarmonyOS 半屏时间弹窗 -鸿蒙开发者社区

HarmonyOS
2025-01-09 15:14:37
1259浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

具体使用参考以下文档:

https://gitee.com/openharmony-sig/ohos-PickerView#%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textpicker-V5#示例

@Entry
@Component
struct DilogDemo {
  @State textValue: string = ''
  dialogController: CustomDialogController = new CustomDialogController({
    builder: TimeSelectDialog(),
    autoCancel: true,
    alignment: DialogAlignment.Bottom,
    customStyle: true,
  })

  build() {
    Column({ space: 10 }) {
      Text('TimeSelectDialog')
        .onClick(() => {
          this.dialogController.open()
        })
    }.width('100%').margin({ top: 5 })
  }
}

class bottom {
  bottom: number = 50
}

let bott: bottom = new bottom()

@CustomDialog
export struct TimeSelectDialog {
  controller: CustomDialogController = new CustomDialogController({
    builder: TimeSelectDialog({}),
  })
  private years: string[] = ['1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999',
    '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012',
    '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025',
    '2026', '2027', '2028', '2029', '2030']
  private months: string[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
  private hours: string[] =
    ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
      '21', '22', '23', '24'];
  private minutes: string[] =
    ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
      '21', '22', '23',
      '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43',
      '44', '45', '46', '47', '48',
      '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'];
  private seconds: string[] =
    ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
      '21', '22', '23',
      '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43',
      '44', '45', '46', '47', '48',
      '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'];
  private multi: string[][] = [this.years, this.months, this.hours, this.minutes, this.seconds]

  build() {
    Column() {
      TextPicker({ range: this.multi })
        .onChange((value: string | string[], index: number | number[]) => {
          console.info('TextPicker 多列:onChange ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index))
        }).margin(bott)
    }
  }
}
  • 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.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
分享
微博
QQ
微信
回复
2025-01-09 18:33:31
相关问题
HarmonyOS bindSheet模态弹窗
1491浏览 • 1回复 待解决
HarmonyOS 如何实现页面?
747浏览 • 1回复 待解决
HarmonyOS 如何实现展开
1007浏览 • 1回复 待解决
基于bindSheet的模态弹窗
2029浏览 • 1回复 待解决
HarmonyOS 希望提供浮层Demo
557浏览 • 1回复 待解决
HarmonyOS 简单的时间弹窗提示
545浏览 • 1回复 待解决
如何展示一个广告
1457浏览 • 1回复 待解决
是否有符合要求的弹窗组件
2603浏览 • 1回复 待解决
模态弹窗如何禁止两边触摸
894浏览 • 0回复 待解决
如何通过路由的方式打开
790浏览 • 1回复 待解决
HarmonyOS时间由应用自己控制
1173浏览 • 1回复 待解决