HarmonyOS 鸿蒙Next 半屏时间弹窗实现滚动日历功能 比如选择2月对应日期只有28天滚动
HarmonyOS 鸿蒙Next 半屏时间弹窗实现滚动日历功能 比如选择2月对应日期只有28天滚动
半屏时间弹窗需要实现滚动日历功能 比如选择2月对应日期只有28天滚动
@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)
}
}
}
更多关于HarmonyOS 鸿蒙Next 半屏时间弹窗实现滚动日历功能 比如选择2月对应日期只有28天滚动的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
可以参考下示例5的省市联动,自己实现一个主子联动
更多关于HarmonyOS 鸿蒙Next 半屏时间弹窗实现滚动日历功能 比如选择2月对应日期只有28天滚动的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
回到顶部