feat(Calendar): expose getSelectedDate method

This commit is contained in:
Alan Wang 2022-07-04 20:34:20 +08:00 committed by GitHub
parent d712da5778
commit 419a8e4f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 0 deletions

View File

@ -214,6 +214,8 @@ export default defineComponent({
return !currentDate.value;
});
const getSelectedDate = () => currentDate.value;
// calculate the position of the elements
// and find the elements that needs to be rendered
const onScroll = () => {
@ -554,6 +556,7 @@ export default defineComponent({
useExpose<CalendarExpose>({
reset,
scrollToDate,
getSelectedDate,
});
onMountedOrActivated(init);

View File

@ -348,6 +348,7 @@ Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get Calend
| --- | --- | --- | --- |
| reset | Reset selected date, will reset to default date when no params passed | _date?: Date \| Date[]_ | - |
| scrollToDate | Scroll to date | _date: Date_ | - |
| getSelectedDate | get selected date | - | _Date \| Date[] \| null_ |
### Types

View File

@ -354,6 +354,7 @@ export default {
| --- | --- | --- | --- |
| reset | 将选中的日期重置到指定日期,未传参时会重置到默认日期 | _date?: Date \| Date[]_ | - |
| scrollToDate | 滚动到某个日期 | _date: Date_ | - |
| getSelectedDate | 获取选中的日期 | - | _Date \| Date[] \| null_ |
### 类型定义

View File

@ -29,6 +29,7 @@ export type CalendarDayItem = {
export type CalendarExpose = {
reset: (date?: Date | Date[]) => void;
scrollToDate: (targetDate: Date) => void;
getSelectedDate: () => Date | Date[] | null;
};
export type CalendarInstance = ComponentPublicInstance<