mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Calendar): expose getSelectedDate method
This commit is contained in:
parent
d712da5778
commit
419a8e4f0e
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -354,6 +354,7 @@ export default {
|
||||
| --- | --- | --- | --- |
|
||||
| reset | 将选中的日期重置到指定日期,未传参时会重置到默认日期 | _date?: Date \| Date[]_ | - |
|
||||
| scrollToDate | 滚动到某个日期 | _date: Date_ | - |
|
||||
| getSelectedDate | 获取选中的日期 | - | _Date \| Date[] \| null_ |
|
||||
|
||||
### 类型定义
|
||||
|
||||
|
@ -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<
|
||||
|
Loading…
x
Reference in New Issue
Block a user