1、DatePicker中不支持关闭循环,没有相关的API接口可以实现该功能。当前规避的手段只能通过TextPicker自定义一个日期组件,TextPicker中有.canLoop(false)可以关闭循环选择。2、您可以通过TextPicker自定义实现月份显示前置0,可参考democlass bottom { bottom:number = 50 } let bott:bottom = new bottom() @Entry @Component struct DatePickerDialogDemo { aboutToAppear() { for (let j = 1990; j <= 2030; j++) { this.years.push(''+j+'年') } for (let z = 1; z <= 12; z++) { if(z<10){ this.months.push('0'+z+'月') }else{ this.months.push(''+z+'月') } } } private years: string[]=[] private months: string[]=[] private multi: string[][] = [this.years, this.months] build() { Column() { TextPicker({ range: this.multi }) .canLoop(false) .onChange((value: string | string[], index: number | number[]) => { console.info('TextPicker 多列:onChange ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)) }).margin(bott) } } }
1、DatePicker中不支持关闭循环,没有相关的API接口可以实现该功能。
当前规避的手段只能通过TextPicker自定义一个日期组件,TextPicker中有.canLoop(false)可以关闭循环选择。
2、您可以通过TextPicker自定义实现月份显示前置0,可参考demo