更新记录
1.0.0(2025-08-02) 下载此版本
首次更新
平台兼容性
uni-app(4.22)
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | - | √ | - | 10.0 | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | - | - | - | - | - | - | - | - | - | - |
uni-app x(4.22)
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
√ | - | 10.0 | - | - | √ |
@ -1,117 +0,0 @@
fh-Calendar 日历节假日组件
一个美观且功能丰富的 UniApp 日历组件,可显示中国节假日、农历日期,并支持多种主题。
功能特点
- 显示当前月份,并提供导航控制(上/下个月,上/下一年)
- 显示每天的农历日期
- 高亮显示中国节假日(包括公历和农历节日)
- 支持多种主题(暗黑、明亮、护眼)
- 高亮显示周末和当天日期
- 可选择并高亮特定日期
- 可自定义当前显示日期
- 提供日期选择、月份/年份变更和主题切换的事件回调
安装方法
- 将
components/fh-calendar
文件夹复制到您的项目中 - 在页面中注册该组件
使用方法
<template>
<fh-calendar-holidays
:theme="currentTheme"
:custom-date="customDate"
:show-theme-switcher="showThemeSwitcher"
:auto-select-today="autoSelectToday"
:showLunar="true"
@day-click="onDayClick"
@month-change="onMonthChange"
@year-change="onYearChange"
@theme-change="onThemeChange"
></fh-calendar-holidays>
</template>
<script>
import fhCalendarHolidays from '@/components/fh-calendar/fh-calendar.vue';
export default {
components: {
fhCalendarHolidays
},
data() {
return {
currentTheme: 'dark', // 'dark'(暗黑), 'light'(明亮), 或 'eye-care'(护眼)
customDate: '2023-05-01', // 可选的自定义日期 (YYYY-MM-DD格式)
showThemeSwitcher: true, // 是否显示主题切换器
autoSelectToday: true // 是否自动选择今天的日期
}
},
methods: {
onDayClick(day) {
console.log('点击了日期:', day);
// day对象包含: date, day, month, year, isCurrentMonth, isToday, isWeekend, lunar, holiday
},
onMonthChange(data) {
console.log(`月份变更为 ${data.year}-${data.month}`);
},
onYearChange(year) {
console.log(`年份变更为 ${year}`);
},
onThemeChange(theme) {
console.log(`主题变更为 ${theme}`);
}
}
}
</script>
属性
属性 | 类型 | 默认值 | 说明 |
---|---|---|---|
theme | String | 'dark' | 日历主题 ('dark'暗黑, 'light'明亮, 或 'eye-care'护眼) |
showThemeSwitcher | Boolean | false | 是否在日历中显示主题切换器 |
customDate | String | '' | 要显示的自定义日期 (格式: YYYY-MM-DD) |
autoSelectToday | Boolean | true | 是否自动选择今天的日期 |
showLunar | Boolean | true | 是否显示农历日期 |
事件
事件 | 参数 | 说明 |
---|---|---|
day-click | day对象 | 点击日期时触发 |
month-change | { year, month } | 月份变更时触发 |
year-change | year | 年份变更时触发 |
theme-change | theme | 主题变更时触发 |
Day对象结构
传递给 day-click
事件的 day 对象具有以下属性:
{
date: Date, // JavaScript Date对象
day: Number, // 月份中的日期 (1-31)
month: Number, // 月份 (1-12)
year: Number, // 年份 (例如 2023)
isCurrentMonth: Boolean, // 该日期是否属于当前月份
isToday: Boolean, // 该日期是否是今天
isWeekend: Boolean, // 该日期是否是周末
lunar: String, // 农历日期
holiday: String // 节假日名称 (如果适用)
}
主题
该组件自带三种内置主题:
- 暗黑主题 (Dark) - 深色背景,浅色文字
- 明亮主题 (Light) - 浅色背景,深色文字
- 护眼主题 (Eye-care) - 柔和的绿色主题,设计用于减轻眼睛疲劳
许可证
MIT