Calendar 最全日历 
由于插件市场上提供的日历插件不是不能满足滑动需求,就是不能满足动态滑动计算需求等问题。
所以我们提供了目前插件市场上唯一支持动态滑动计算的日历插件,多滑动切换模式(纵、横、不滑动)、多日历类型(周、月日历)、多日期选择模式(日期单选、日期多选、日期范围选择)、多日历起始周几(周日、周一)、自定义主题颜色、自定义文案、农历显示,可以让您纵享丝滑的使用日历。
为了开发者更便捷的使用日历,我们已在旁边的演示手机内集成了日历动态代码复制功能,可以直接在上面进行任何操作然后点击标题即可复制目前操作下的日历代码(完全的动态代码,粘贴即可使用)。
平台兼容性 
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 | 
|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | 
基本使用(插入模式) 
通过设置 insert 属性为 true,日历会直接显示在页面中,选择时会触发 change 事件
<template>
	<view class="index">
		<wu-calendar :insert="true" @change="calendarChange"></wu-calendar>
	</view>
</template>
<script>
	export default {
		methods: {
			calendarChange(e) {
				console.log(e);
			}
		}
	}
</script><template>
	<view class="index">
		<wu-calendar :insert="true" @change="calendarChange"></wu-calendar>
	</view>
</template>
<script>
	export default {
		methods: {
			calendarChange(e) {
				console.log(e);
			}
		}
	}
</script>弹窗模式 
通过设置 insert 属性为 false,并通过日历的 ref 触发 open 方法来使用弹窗模式下的日历,点击确定时会触发 confirm 事件
<template>
	<view class="index">
		<wu-calendar ref="calendar" @confirm="calendarConfirm" :insert="false"></wu-calendar>
		<button @click="open">打开日历</button>
	</view>
</template>
<script>
	export default {
		methods: {
			calendarConfirm(e) {
				console.log(e);
			},
            // 打开日历
            open() {
                this.$refs.calendar.open();
            }
		}
	}
</script><template>
	<view class="index">
		<wu-calendar ref="calendar" @confirm="calendarConfirm" :insert="false"></wu-calendar>
		<button @click="open">打开日历</button>
	</view>
</template>
<script>
	export default {
		methods: {
			calendarConfirm(e) {
				console.log(e);
			},
            // 打开日历
            open() {
                this.$refs.calendar.open();
            }
		}
	}
</script>滑动切换模式 
我们实现了动态的滑动切换计算过程,可以在您切换完成时,动态计算前后两个月份。
通过设置 slideSwitchMode 属性来指定滑动切换的模式,默认为 horizontal。
horizontal横向滑动切换vertical纵向滑动切换none不使用滑动切换
<wu-calendar slideSwitchMode="vertical"></wu-calendar><wu-calendar slideSwitchMode="vertical"></wu-calendar>日历类型 
通过设置 type 属性来指定日历类型,默认为 month。
month月日历week周日历
这两种日历类型都支持折叠效果, 也可以通过 fold 来指定是否支持折叠。
month的fold默认为falseweek的fold默认为true
<wu-calendar type="month" :fold="false"></wu-calendar><wu-calendar type="month" :fold="false"></wu-calendar>日历以周几开始 
通过设置 startWeek 属性来指定日历以周几开始,默认为 sun。
sun周日mon周一
<wu-calendar type="month" :fold="true" startWeek="mon"></wu-calendar><wu-calendar type="month" :fold="true" startWeek="mon"></wu-calendar>日期单选 
mode属性为single, 启用日期单选(默认即是日期单选)。- 此模式下默认值通过 
date来设置,格式为字符。 
<wu-calendar date="2024-11-23"></wu-calendar><wu-calendar date="2024-11-23"></wu-calendar>日期多选 
- 需要通过设置 
mode属性为multiple, 来启用日期多选。 - 此模式下默认值通过 
date来设置,格式为数组。 
<wu-calendar mode="multiple" :date="['2024-11-23', '2024-11-27', '2024-11-30']"></wu-calendar><wu-calendar mode="multiple" :date="['2024-11-23', '2024-11-27', '2024-11-30']"></wu-calendar>日期范围选择 
- 需要通过设置 
mode属性为range, 来启用日期范围选择。 - 此模式下默认值通过 
date来设置,格式为数组。 
<wu-calendar mode="range" :date="['2024-11-25', '2024-12-15']"></wu-calendar><wu-calendar mode="range" :date="['2024-11-25', '2024-12-15']"></wu-calendar>默认日期 
useToday 默认为 true ,在不传入 date 时,会使用今天来作为默认日期。
mode 为不同模式时会有不同的效果.
single(单选)模式会选中今天的日期multiple(多选)模式会将数组第一个变为今天的日期range(范围选择)模式会将开始日期变为今天的日期
如果不想使用默认日期可以将 useToday 设置为 false。
<wu-calendar mode="single" :useToday="false"></wu-calendar><wu-calendar mode="single" :useToday="false"></wu-calendar>设置日期可选范围 
可以通过 startDate 与 endDate 来设置日期可选范围。
startDate开始日期endDate结束日期
<wu-calendar startDate="2024-11-25" endDate="2024-12-25"></wu-calendar><wu-calendar startDate="2024-11-25" endDate="2024-12-25"></wu-calendar>日期范围同一天 
需要通过设置 rangeSameDay 属性为 true , 来允许日期选择范围起始为同一天(需要开启日期范围选择)。
<wu-calendar mode="range" :rangeSameDay="true"></wu-calendar><wu-calendar mode="range" :rangeSameDay="true"></wu-calendar>选择范围内重选结束日期 
需要通过设置 rangeEndRepick 属性为 true , 来启用选择完成后点击选择范围的日期内来重选结束日期(需要开启日期范围选择)。
<wu-calendar mode="range" :rangeEndRepick="true"></wu-calendar><wu-calendar mode="range" :rangeEndRepick="true"></wu-calendar>选择范围内遇到打点禁用日期进行截断 
需要通过设置 rangeHaveDisableTruncation 属性为 true , 来启用选择范围内遇到打点禁用日期进行截断(需要开启日期范围选择)。
如果允许进行截断的话,会以第一个打点禁用日期的前一个日期作为选择范围的结束日期
<wu-calendar mode="range" :rangeHaveDisableTruncation="true"></wu-calendar><wu-calendar mode="range" :rangeHaveDisableTruncation="true"></wu-calendar>农历显示 
需要通过设置 lunar属性为 true, 来启用日历的农历显示。
<wu-calendar :lunar="true"></wu-calendar><wu-calendar :lunar="true"></wu-calendar>每月是否仅展示当月数据 
需要通过设置 monthShowCurrentMonth 属性为 true, 来启用每月仅展示当月数据。
<wu-calendar :monthShowCurrentMonth="true"></wu-calendar><wu-calendar :monthShowCurrentMonth="true"></wu-calendar>自定义主题颜色 
通过设置 color 属性来指定自定义主题颜色,会通过 wu-ui 的 Color API 自动生成自定义主题色的其余配色,让您可以随意设置主题色,且不会显得突兀。
<wu-calendar color="#6ac695"></wu-calendar><wu-calendar color="#6ac695"></wu-calendar>自定义文案 
通过 selected 属性来实现自定义日期
<template>
	<view class="index">
		<wu-calendar 
            :selected="selected" 
            ref="calendar" 
            @confirm="calendarConfirm" 
            :insert="false"
        ></wu-calendar>
		<button @click="open">打开日历</button>
	</view>
</template>
<script>
	export default {
        data() {
            return {
                // 指定三个日期的自定义文案 昨天、后两天、后五天的自定义文案
                // 除了变量声明,函数 计算属性方式只要返回格式正确都可以使用自定义文案
				selected: [
                    {
                        date: '2024-11-24',
                        info: '¥850',
                        infoColor: '#6ac695',
                        topInfo: '打折',
                        topInfoColor: '#6ac695',
                        badgeColor: 'red',
                        disable: true // 禁用
                    },
                    {
                        date: '2024-11-27',
                        info: '¥950',
                        infoColor: '#6ac695',
                        topInfo: '打折',
                        topInfoColor: '#6ac695',
                        badgeColor: 'red'
                    },
                    {
                        date: '2024-11-30',
                        info: '¥900',
                        infoColor: '#6ac695',
                        topInfo: '打折',
                        topInfoColor: '#6ac695',
                        badgeColor: 'red' 
                    },
                ]
			}
        },
		methods: {
			calendarConfirm(e) {
				console.log(e);
			},
            // 打开日历
            open() {
                this.$refs.calendar.open();
            },
		}
	}
</script><template>
	<view class="index">
		<wu-calendar 
            :selected="selected" 
            ref="calendar" 
            @confirm="calendarConfirm" 
            :insert="false"
        ></wu-calendar>
		<button @click="open">打开日历</button>
	</view>
</template>
<script>
	export default {
        data() {
            return {
                // 指定三个日期的自定义文案 昨天、后两天、后五天的自定义文案
                // 除了变量声明,函数 计算属性方式只要返回格式正确都可以使用自定义文案
				selected: [
                    {
                        date: '2024-11-24',
                        info: '¥850',
                        infoColor: '#6ac695',
                        topInfo: '打折',
                        topInfoColor: '#6ac695',
                        badgeColor: 'red',
                        disable: true // 禁用
                    },
                    {
                        date: '2024-11-27',
                        info: '¥950',
                        infoColor: '#6ac695',
                        topInfo: '打折',
                        topInfoColor: '#6ac695',
                        badgeColor: 'red'
                    },
                    {
                        date: '2024-11-30',
                        info: '¥900',
                        infoColor: '#6ac695',
                        topInfo: '打折',
                        topInfoColor: '#6ac695',
                        badgeColor: 'red' 
                    },
                ]
			}
        },
		methods: {
			calendarConfirm(e) {
				console.log(e);
			},
            // 打开日历
            open() {
                this.$refs.calendar.open();
            },
		}
	}
</script>API 
Selected Options 
自定义日期内容属性,可以设置多个日期,类型为 Array[Object]。
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 
|---|---|---|---|---|
| date | 日期,格式: YYYY-mm-dd | String | - | - | 
| info | 下方文案 | String | - | - | 
| infoColor | 下方文案颜色 | String | #e43d33 | - | 
| topInfo | 上方文案 | String | - | - | 
| topInfoColor | 上方文案颜色 | String | #e43d33 | - | 
| badge | 是否显示圆点 | Boolean | false | true / false | 
| badgeColor 1.4.5 | 圆点颜色 | String | #e43d33 | - | 
| badgeSize 1.3.0 | 圆点大小 | String | 16rpx | - | 
| badgePosition | 圆点显示的位置 | String | top-right | top-left / top-center / top-right / bottom-left / bottom-center / bottom-right | 
| disable | 是否禁用 | Boolean | false | true / false | 
Calendar Props 
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 
|---|---|---|---|---|
| date | 自定义默认选中时间,默认为今天,mode="multiple"或"range"时,该值需为数组,mode="single",该值为字符串 | String | 今天的日期 | - | 
| mode | 日期选择类型 | String | single | single-单日期 / multiple-多日期 / range-日期范围选择 | 
| type 1.3.0 | 日历类型 | String | month | month-月日历 / week-周日历 | 
| fold 1.3.0 | 是否支持折叠 | Boolean | month: true, week: false | true / false | 
| startWeek 1.3.0 | 日历以周几开始 | String | sun | sun-周日 / mon-周一 | 
| maskClick | 是否点击遮罩层关闭 | Boolean | false | true / false | 
| useToday | 是否使用默认日期(今天) | Boolean | true | true / false | 
| todayDefaultStyle 1.5.6 | 是否显示今日默认样式 | Boolean | true | true / false | 
| lunar | 是否显示农历日期 | Boolean | false | true / false | 
| monthShowCurrentMonth | 每月是否仅显示当月数据 | Boolean | false | true / false | 
| rangeSameDay | 日期选择范围起始为同一天 | Boolean | false | true / false | 
| rangeEndRepick | 选择完成后点击选择范围的日期内来重选结束日期 | Boolean | false | true / false | 
| rangeHaveDisableTruncation 1.3.1 | 日期选择范围内遇到打点禁用日期进行截断 | Boolean | false | true / false | 
| startDate | 日期范围选择-开始日期 | String | - | - | 
| endDate | 日期范围选择-结束日期 | String | - | - | 
| insert | 插入模式,true: 插入模式; false: 弹窗模式 | Boolean | true | true / false | 
| slideSwitchMode | 滑动切换模式 | String | horizontal | horizontal/ vertical / none | 
| showMonth | 是否显示月份为背景 | Boolean | true | true / false | 
| clearDate | 弹窗模式是否清空上次选择内容 | Boolean | true | true / false | 
| disabledChoice | 是否禁止点击日历 | Boolean | false | true / false | 
| selected | 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] | Array[Object] | - | 查看自定义文案示例,Selected Options参数详情 | 
| color | 自定义主题色 | String | #3c9cff | - | 
| itemHeight 1.3.7 | 日历中每项日期的高度,单位px | Number | 64 | - | 
| cancelColor | 取消文字的颜色 | String | #333333 | - | 
| confirmColor | 确定文字的颜色 | String | #333333 | - | 
| startText | mode=range时,第一个日期底部的提示文字 | String | 开始 | - | 
| endText | mode=range时,最后一个日期底部的提示文字 | String | 结束 | - | 
| actBadgeColor 1.4.6 | 当通过 selected 属性设置某个日期 badgeColor后,如果该日期被选择且主题色与 badgeColor 一致时,徽标会显示本颜色 | String | #fff | - | 
| operationPosition 1.4.7 | 弹窗日历取消和确认按钮的显示位置 | String | top | top / bottom | 
| confirmFullDate 1.5.0 | 弹窗日历确认按钮点击时是否需要选择完整日期 | Boolean | false | true / false | 
Calendar Methods 
| 方法名 | 说明 | 
|---|---|
| open | insert 为 false 时,调用此方法弹出日历组件 | 
| close | insert 为 false 时,调用此方法关闭日历组件 | 
| reset 1.4.5 | 重置日历数据 | 
| clearSelect 1.5.6 | 清除日历选择 | 
Calendar Events 
| 事件名 | 说明 | 返回参数 | 
|---|---|---|
| close | 点击日历弹窗遮罩层触发关闭时触发 | - | 
| cancel 1.4.5 | insert 为 false 时,点击取消按钮时触发 | - | 
| confirm | insert 为 false 时,点击确认按钮时触发 | 返回日期相关参数 | 
| change | insert 为 true 时,选择日期时触发 | 返回日期相关参数 | 
| monthSwitch | 切换月份时触发 | {year, month, fullDate} | 
| foldSwitch 1.3.0 | 切换折叠状态时触发 | {type, status} | 
Calendar Slots 
| 插槽名 | 说明 | 
|---|---|
| header | 日历头部自定义插槽 | 
| operation | 弹窗日历取消和确认按钮插槽 | 
v-slot:header 
| 值名称 | 说明 | 
|---|---|
| nowDate | 目前所在月份时间数据 | 
WU-UI