Skip to content

Calendar日历

基础用法

设置modelValue展示对应日期,未指定展示当前日期

2025年10月11日
星期日星期一星期二星期三星期四星期五星期六
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
vue
<script setup lang="ts">
import { ref } from 'vue';
const currentDate = ref(new Date())
</script>
<vt-calendar v-model="currentDate">
</vt-calendar>

自定义内容

通过设置名为 date-cell 的 scoped-slot 来自定义日历单元格中显示的内容。 在 scoped-slot 可以获取到 date(当前单元格的日期), data(包括 type,isSelected,day 属性)。 详情解释参考下方的 API 文档。

2025年10月11日
星期日星期一星期二星期三星期四星期五星期六

09-28

09-29

09-30

10-01

10-02

10-03

10-04

10-05

10-06

10-07

10-08

10-09

10-10

10-11

10-12

10-13

10-14

10-15

10-16

10-17

10-18

10-19

10-20

10-21

10-22

10-23

10-24

10-25

10-26

10-27

10-28

10-29

10-30

10-31

11-01

11-02

11-03

11-04

11-05

11-06

11-07

11-08

vue
<vt-calendar v-model="currentDate">
  <template #date-cell="{ data }">
    <p :class="data.isSelected ? 'is-selected' : ''">
      {{ data.day.split('-').slice(1).join('-') }}
      {{ data.isSelected ? '√' : '' }}
    </p>
  </template>
</vt-calendar>

API

属性

名称类型默认值说明
modelValuestring-使用v-model绑定需要展示日期

插槽

名称类型说明
date-cellobject格式是单元格日期

Released under the MIT license.