Files
heroui-vue/apps/docs/demos/calendar-multiple-selection.vue
T
2026-10-24 20:59:19 +08:00

40 lines
1.2 KiB
Vue

<script setup lang="ts">
import {
Calendar,
CalendarHeader,
CalendarHeading,
CalendarNavButton,
CalendarGrid,
CalendarGridHeader,
CalendarGridBody,
CalendarHeaderCell,
CalendarCell,
Description,
} from "@heroui-vue/components";
import { shallowRef } from "vue";
import type { DateValue } from "@internationalized/date";
const value = shallowRef<DateValue[] | null>([]);
</script>
<template>
<div class="flex flex-col items-center gap-4">
<Calendar aria-label="活动日期" selection-mode="multiple" v-model="value">
<CalendarHeader>
<CalendarHeading />
<CalendarNavButton slot="previous" />
<CalendarNavButton slot="next" />
</CalendarHeader>
<CalendarGrid>
<CalendarGridHeader v-slot="{ day }">
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
</CalendarGridHeader>
<CalendarGridBody v-slot="{ date }">
<CalendarCell :date="date" />
</CalendarGridBody>
</CalendarGrid>
</Calendar>
<Description class="text-center">
{{ value?.length ? `已选择 ${value.length} 个日期` : "可选择多个日期" }}
</Description>
</div>
</template>