Yt-UI
首页
快速开始
组件文档
首页
快速开始
组件文档
  • 表单组件

    • 输入框 Input
    • 多行输入框 Textarea
    • 开关 Switch
    • 多选框组 CheckboxGroup
    • 单选框组 RadioGroup
    • 滑块 Slider
    • 选择器 Picker
    • 日历 Calendar
    • 表单 Form
  • 展示组件

    • 头像 Avatar
    • 徽标 Badge
    • 卡片 Card
    • 标签 Tag
    • 步骤条 Steps
    • 结果页 Result
    • 空状态 Empty
    • 虚拟列表 VirtualList
  • 交互组件

    • 按钮 Button
    • 悬浮按钮 FAB
    • 图标 Icon
    • 搜索 Search
    • 分段器 Segment
    • 轮播 Swiper
    • 指示点 Dots
  • 反馈组件

    • 加载 Loading
    • 弹窗 Popup
    • 遮罩层 Overlay
    • 通告栏 NoticeBar
  • 导航组件

    • 标签栏 Tabbar
    • 顶部标签栏 TopTabbar
    • 折叠面板 Collapse
    • 课程表 Schedule
  • 布局组件

    • 分割线 Divider
    • 链接 Line
    • 可移动视图 MovableView

yt-calendar 日历组件

属性

属性名类型默认值说明
monthDataMonthData[][]月份数据
loadingbooleanfalse是否加载中
themeThemeColor | 'none''none'主题颜色
widthnumber | string'100%'日历宽度
heightnumber | string'100%'日历高度
gapnumber | string6日期项间距
borderRadiusnumber | string10圆角大小
startstring''可选开始日期 (YYYY-MM)
endstring''可选结束日期 (YYYY-MM)

事件

事件名参数说明
change{ year: number; month: number }月份切换
dateClick{ year: number; month: number; date: number; index: number }日期点击

MonthData 类型

type MonthData = {
  date: number // 日期 (1-31)
  extra: string // 额外信息显示
  isHoliday: boolean // 是否节假日
}[]

示例

基本使用

<yt-calendar />
<yt-calendar theme="forest" />
<yt-calendar theme="ocean" />
<yt-calendar theme="magic" />
<yt-calendar theme="blossom" />
<yt-calendar theme="sunshine" />
<yt-calendar theme="classic" />
<yt-calendar theme="forest-sky" />
<yt-calendar theme="ocean-sky" />
<yt-calendar theme="magic-sky" />
<yt-calendar theme="blossom-sky" />
<yt-calendar theme="sunshine-sky" />

自定义尺寸

<yt-calendar :width="300" :height="400" theme="forest" />
<yt-calendar width="90vw" height="60vh" theme="ocean" />
<yt-calendar :gap="8" :borderRadius="12" theme="magic" />

日期范围

<yt-calendar start="2024-01" end="2024-12" theme="blossom" />
<yt-calendar start="2024-06" end="2024-12" theme="sunshine" />
<yt-calendar start="2024-01" end="2024-06" theme="classic" />

自定义月份数据

<script setup>
  const monthData = [
    { date: 1, extra: '元旦', isHoliday: true },
    { date: 10, extra: '加班', isHoliday: false },
    { date: 15, extra: '会议', isHoliday: false },
    { date: 20, extra: '春节', isHoliday: true }
  ]
</script>

<template>
  <yt-calendar
    :monthData="monthData"
    theme="forest-sky"
  />
</template>

加载状态

<yt-calendar :loading="true" theme="ocean-sky" />
<yt-calendar :loading="isLoading" theme="magic-sky" />

事件处理

<yt-calendar @change="handleMonthChange" @dateClick="handleDateClick" theme="blossom-sky" />

完整示例

<yt-calendar
  :monthData="holidayData"
  :loading="loading"
  theme="sunshine-sky"
  :width="350"
  :height="450"
  :gap="8"
  :borderRadius="12"
  start="2024-01"
  end="2024-12"
  @change="handleMonthChange"
  @dateClick="handleDateClick"
/>

响应式日历

<yt-calendar
  :width="isMobile ? '100%' : 400"
  :height="isMobile ? 'auto' : 500"
  theme="forest"
  @dateClick="selectDate"
/>
最近更新:: 2026/3/9 19:16
Contributors: CHEEMS, 2126340634
Prev
选择器 Picker
Next
表单 Form