diff --git a/src/calendar/README.md b/src/calendar/README.md index c4e759846..abd7efc2f 100644 --- a/src/calendar/README.md +++ b/src/calendar/README.md @@ -316,7 +316,7 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Calendar instance and call insta | Name | Description | Attribute | Return value | | --- | --- | --- | --- | -| reset | Reset selected date to default date | - | - | +| reset | Reset selected date, will reset to default date when no params passed | _date?: Date \| Date[]_ | - | | scrollToDate `v2.12.2` | Scroll to date | _date: Date_ | - | ### Less Variables diff --git a/src/calendar/README.zh-CN.md b/src/calendar/README.zh-CN.md index 971f491f7..9dca96dc3 100644 --- a/src/calendar/README.zh-CN.md +++ b/src/calendar/README.zh-CN.md @@ -320,10 +320,10 @@ export default { 通过 ref 可以获取到 Calendar 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。 -| 方法名 | 说明 | 参数 | 返回值 | -| ---------------------- | ---------------------- | ------------ | ------ | -| reset | 重置选中的日期到默认值 | - | - | -| scrollToDate `v2.12.2` | 滚动到某个日期 | _date: Date_ | - | +| 方法名 | 说明 | 参数 | 返回值 | +| --- | --- | --- | --- | +| reset | 将选中的日期重置到指定日期,未传参时会重置到默认日期 | _date?: Date \| Date[]_ | - | +| scrollToDate `v2.12.2` | 滚动到某个日期 | _date: Date_ | - | ### 样式变量 diff --git a/src/calendar/index.js b/src/calendar/index.js index 96ba188cd..17e456078 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -171,8 +171,8 @@ export default createComponent({ methods: { // @exposed-api - reset() { - this.currentDate = this.getInitialDate(); + reset(date = this.getInitialDate()) { + this.currentDate = date; this.scrollIntoView(); }, diff --git a/types/calendar.d.ts b/types/calendar.d.ts index bc815f8d0..f516e2f06 100644 --- a/types/calendar.d.ts +++ b/types/calendar.d.ts @@ -1,7 +1,7 @@ import { VanComponent } from './component'; export class Calendar extends VanComponent { - reset(): void; + reset(date?: Date | Date[]): void; scrollToDate(date: Date): void; }