diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md
index 9eb6ea3b66e032f8a441b65e509759dda062a37f..1ef16e32d86c20e5846aaee774ba87680d1b15c3 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md
@@ -68,9 +68,10 @@ DatePicker(options?: {start?: Date, end?: Date, selected?: Date})
除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件:
-| 名称 | 功能描述 |
-| ---------------------------------------- | ----------- |
-| onChange(callback: (value: DatePickerResult) => void) | 选择日期时触发该事件。 |
+| 名称 | 功能描述 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| onChange(callback: (value: DatePickerResult) => void)(deprecated) | 选择日期时触发该事件。
**说明:**
从API version 8 开始支持,从 API version 10 开始废弃,建议使用onDateChange(callback: (value: Date) => void)。 |
+| onDateChange(callback: (value: Date) => void)10+ | 选择日期时触发该事件。 |
## DatePickerResult对象说明
@@ -108,9 +109,9 @@ struct DatePickerExample {
.textStyle({color: '#ff182431', font: {size: '18fp', weight: FontWeight.Normal}})
.selectedTextStyle({color: '#ff0000FF', font: {size: '26fp', weight: FontWeight.Regular}})
.lunar(this.isLunar)
- .onChange((value: DatePickerResult) => {
- this.selectedDate.setFullYear(value.year, value.month, value.day)
- console.info('select current date is: ' + JSON.stringify(value))
+ .onDateChange((value: Date) => {
+ this.selectedDate = value
+ console.info('select current date is: ' + value.toString())
})
}.width('100%')
diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md
index 5fa377760f5659035aca6ad1aa8f2ced4841a889..115bafbc70ed614e1a14d4a77ee27b4771d44e92 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md
@@ -29,9 +29,11 @@ show(options?: DatePickerDialogOptions)
| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。
默认值:
{
color: '#ff182431',
font: {
size: '14fp',
weight: FontWeight.Regular
}
} |
| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。
默认值:
{
color: '#ff182431',
font: {
size: '16fp',
weight: FontWeight.Regular
}
} |
| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置选中项的文本颜色、字号、字体粗细。
默认值:
{
color: '#ff007dff',
font: {
size: '20vp',
weight: FontWeight.Medium
}
} |
-| onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 |
+| onAccept(deprecated) | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。
**说明:**
从API version 8 开始支持,从 API version 10 开始废弃,建议使用onDateAccept。 |
| onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 |
-| onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。 |
+| onChange(deprecated) | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。
**说明:**
从API version 8 开始支持,从 API version 10 开始废弃,建议使用onDateChange。 |
+| onDateAccept10+ | (value: Date) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。
**说明:**
当showTime设置为true时,回调接口返回值value中时和分为选择器选择的时和分。否则,返回值value中时和分为系统时间的时和分。 |
+| onDateChange10+ | (value: Date) => void | 否 | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。
**说明:**
当showTime设置为true时,回调接口返回值value中时和分为选择器选择的时和分。否则,返回值value中时和分为系统时间的时和分。 |
**异常情形说明:**
@@ -76,16 +78,16 @@ struct DatePickerDialogExample {
disappearTextStyle: {color: Color.Pink, font: {size: '22fp', weight: FontWeight.Bold}},
textStyle: {color: '#ff00ff00', font: {size: '18fp', weight: FontWeight.Normal}},
selectedTextStyle: {color: '#ff182431', font: {size: '14fp', weight: FontWeight.Regular}},
- onAccept: (value: DatePickerResult) => {
+ onDateAccept: (value: Date) => {
// 通过Date的setFullYear方法设置按下确定按钮时的日期,这样当弹窗再次弹出时显示选中的是上一次确定的日期
- this.selectedDate.setFullYear(value.year, value.month, value.day)
- console.info("DatePickerDialog:onAccept()" + JSON.stringify(value))
+ this.selectedDate = value
+ console.info("DatePickerDialog:onDateAccept()" + value.toString())
},
onCancel: () => {
console.info("DatePickerDialog:onCancel()")
},
- onChange: (value: DatePickerResult) => {
- console.info("DatePickerDialog:onChange()" + JSON.stringify(value))
+ onDateChange: (value: Date) => {
+ console.info("DatePickerDialog:onDateChange()" + value.toString())
}
})
})
@@ -101,15 +103,15 @@ struct DatePickerDialogExample {
disappearTextStyle: {color: Color.Pink, font: {size: '22fp', weight: FontWeight.Bold}},
textStyle: {color: '#ff00ff00', font: {size: '18fp', weight: FontWeight.Normal}},
selectedTextStyle: {color: '#ff182431', font: {size: '14fp', weight: FontWeight.Regular}},
- onAccept: (value: DatePickerResult) => {
- this.selectedDate.setFullYear(value.year, value.month, value.day)
- console.info("DatePickerDialog:onAccept()" + JSON.stringify(value))
+ onDateAccept: (value: Date) => {
+ this.selectedDate = value
+ console.info("DatePickerDialog:onDateAccept()" + value.toString())
},
onCancel: () => {
console.info("DatePickerDialog:onCancel()")
},
- onChange: (value: DatePickerResult) => {
- console.info("DatePickerDialog:onChange()" + JSON.stringify(value))
+ onDateChange: (value: Date) => {
+ console.info("DatePickerDialog:onDateChange()" + value.toString())
}
})
})