Skip to content
你当前查看的文档是tmui3.2.0(已不再支持NVUE)
[tmui3.1.x nvue点我] [tmui4.x uniappx原生开发代替nvue]

表单组件

日历 tmCalendarMultiple

以单选和多选,无限循环滚动

🌶️ 示例

查看模拟效果
示例模板
vue
<template>
	<view>
		<tm-sheet>
			<tm-text font-size="32" class=" text-weight-b mb-16 d-block">日历 tmCalendarMultiple</tm-text>
			<tm-text color="#999999">
				可以多选,单选,同天不可选(酒店)模式
			</tm-text>
		</tm-sheet>


		<tm-sheet :padding="0" class="overflow">
            <tm-calendar-multiple head-bg-color="primary" v-model:currentDate="currentDate" 
			:date-style="dateStyle"
			head-font-color="#fff" :seekDay="6" v-model="dates" model="range" ></tm-calendar-multiple>
			<view class="pa-16">
				<tm-button block @click="setdate">赋值</tm-button>
			</view>
		</tm-sheet>
		<tm-sheet>
			<tm-text font-size="32" class=" text-weight-b mb-16 d-block">单选模式</tm-text>
			<tm-text color="#999999">
				{{days}}
			</tm-text>
		</tm-sheet>
		<tm-sheet :padding="0" class="overflow">
			<tm-calendar-multiple color="error" head-bg-color="error" head-font-color="#fff" :multipleMax="1" :seekDay="6" v-model="days" model="day" ></tm-calendar-multiple>
		</tm-sheet>
	</view>
</template>

<script lang="ts" setup>
import { ref,nextTick } from "vue"
const dateStyle = ref<TM.tmCalendarDateStyle_type[]>([])
const dates = ref<string[]>([])
const currentDate = ref<string>('')
const days = ref<string[]>([])

const setdate = ()=> {
	dates.value = ['2024-5-1','2024-5-8']
	currentDate.value = "2024-5-1"
	nextTick(()=>{
		dateStyle.value = [
			{ date: '2024-5-3', color: '#00aa7f', label: '推荐', fontColor: 'white' },
			{ date: '2024-5-20', label: '完成', fontColor: 'orange' },
			{ date: '2024-5-21', label: '爆满', fontColor: 'red' },
			{ date: '2024-5-31', label: '禁用' },
			{ date: '2024-5-18', dot: true },
			{ date: '2024-5-17', dot: true, dotColor: "orange", dotLabel: "36" },
			{ date: '2024-5-1', dot: true, dotColor: "#52c428", dotLabel: "假", label: "劳动节", fontColor: "#52c428" },
			{ date: '2024-5-4', dot: true, dotColor: "#aa55ff", dotLabel: "休", label: "劳动节", fontColor: "#52c428" },
		]
	})
}

</script>

<style></style>

🌶️ 兼容性

平台兼容

H5uniAPP小程序version
☑️☑️☑️☑️

🌱 参数

参数名类型默认值描述
modelValueArray():string[]=>[]asstring[]同步当前时间v-model不受控:model-value
modelunion'day'范围选择模式day:天数多选,通过multipleMax可以设置允许选择的天数range:天数的范围选择,起始和终止
multipleMaxnumber-1多选模式时,允许选择的最大天数。
disabledDaysArray():string[]=>[]asstring[]禁用的日期字符串如"2023-12-12"它与下面的start,end不冲突。
startDatestring'1900-1-1'允许选择的开始日期
verticalbooleanfalse是否上下切换日历
endDatestring'2100-1-1'允许选择的结束日期
currentDatestring''当前显示的月份,默认以modalValue中的第一项为初始月如果为空,显示本月,可以控制这里切换显示的日期
dateStyleArray():TM.tmCalendarDateStyle_type[]=>[]asTM.tmCalendarDateStyle_type[]设置指定日期的样式数据类型见:TM.tmCalendarDateStyle_type
formatstring'YYYY-MM-DD'同步vmodel时格式化模板
colorstring''选中的主题色,默认空值,取全局主题色如果提供了dateStyle,以dateStyle为准
fontColorstring'#333333'默认的文字颜色如果提供了dateStyle,以dateStyle为准
fontDarkColorstring'#ffffff'默认的暗黑文字颜色如果提供了dateStyle,以dateStyle为准
activeFontColorstring'#ffffff'默认选中时的文字颜色如果提供了dateStyle,以dateStyle为准
rangColorstring''范围选中时,范围中间的选中颜色,如果为空,为color的透明度0.5;
rangFontColorstring''-
headBgColorstring'transparent'头的背景颜色,默认为透明
headFontColorstring''头的文字颜色,提供了后暗黑失效会以这个为准。
headStylestring''头部自定义样式。
renderOnlybooleantrue循环渲染时,是否只渲染当前面板(如果你在pad等10年前的低端机上渲染日历有压力请打开此值为true)关闭后可以提升滑动体验。
seekDaynumber0你当前的一周的第一天的索引值是几:0:周一,1:周二,2:周三,3:周四,4:周五,5:周六,6:周日
dateStatusArray():TM.tmCalendarDateStyleStatusType[]=>[]asTM.tmCalendarDateStyleStatusType[]给日期设定状态类型为:TM.tmCalendarDateStyleStatusType[]
showClearbooleantrue显示清空按钮
showFooterbooleantrue显示页脚
isSameDaybooleantrue是否允许选择同一天

🌹 事件

事件名参数返回数据描述
change名称:value,当前变化的日期,-时间变化时触发
click名称:value,当前被点击的日期,-当前日历面板的日期被点击时触发
currentChange名称:value,当前激活面板的日期,-当前激活面板月份改变时触发(就是当前看到的月份面板)
update:modelValue名称:value,当前选中日期,-同步当前的选中的日期绑定
update:currentDate名称:value,当前查看的月分日期,-同步当前查看的月份日期,请以日期形式提供值

🌽 slot插槽

插槽名数据描述
header-日历头,隐藏使用空插槽,将隐藏,如果想自定,请通过ref函数来翻页控制日历走向。
footer-日历尾部

🥗 ref方法

方法名参数返回值描述
next--下月
prev--上月
setCurrentMonth--设置日历返回到本月
clear--清空选择
如果需投广告联系我?
TMUI4x

TMUI4x UniAppx

纯正原生开发版本,全平台原生组件,兼容鸿蒙Next原生

了解最新技术