Skip to content
Title

Calendar 日历

显示日期

基本使用

2023年7月15日
星期日星期一星期二星期三星期四星期五星期六
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
vue
<template #source>
  <b-calendar v-model="currentDate"></b-calendar>
</template>
<script setup>
import { ref, computed } from 'vue'
const currentDate = ref(new Date())
</script>
展开代码

自定义内容

2023年7月15日
星期日星期一星期二星期三星期四星期五星期六

06-25

06-26

06-27

06-28

06-29

06-30

07-01

07-02

07-03

07-04

07-05

07-06

07-07

07-08

07-09

07-10

07-11

07-12

07-13

07-14

07-15

07-16

07-17

07-18

07-19

07-20

07-21

07-22

07-23

07-24

07-25

07-26

07-27

07-28

07-29

07-30

07-31

08-01

08-02

08-03

08-04

08-05

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

<script setup>
import { ref, computed } from 'vue'
const currentDate = ref(new Date())
</script>
展开代码

API

Calendar 属性

名称说明类型可选项默认值
data绑定值Date
first_day_of_week周起始日Number0-60

Calendar 插槽

参数说明类型可选值默认值
date单元格代表的日期Date
data{ type, isSelected, day},type 表示该日期的所属月份,可选值有 prev-month,current-month,next-month;isSelected 标明该日期是否被选中;day 是格式化的日期,格式为 yyyy-MM-ddObject

Released under the MIT License.