基于riot的日历,默认日历视图由defaultDate|selectDates|new Date()按顺序提供,实例
Methods
-
<inner> riot-calendar(opts)
-
Parameters:
Name Type Description optsobject Properties
Name Type Argument Default Description autoOkboolean <optional>
false 是否自动保存 defaultDatedate <optional>
默认日期 minDatedate <optional>
最小日期 maxDatedate <optional>
最大日期 isRangeboolean <optional>
是否为选择范围 rangeLimitArray.<date> <optional>
选择的范围 weekModeboolean <optional>
false 是否固定星期 true 固定 firstDaynumber <optional>
0 每周的第一天 isMultipleboolean <optional>
是否为多选 selectDatesArray.<date> <optional>
选中的日期 switchViewByOtherMonthboolean <optional>
false 表示点击其它月份是否切换日历视图 switchViewOverLimitboolean <optional>
false 表示超出最小与最大日历是否能切换日历视图 showOtherMonthDatesboolean <optional>
true 是否显示其它月的日期 @since 0.0.3beta1 switchWithAnimationboolean <optional>
true 切换时是否需要动画 animationTimingFunctionstring <optional>
cubic-bezier(0.445, 0.05, 0.55, 0.95) 动画函数 animationDurationnumber <optional>
0.45 动画待续时间 默认为0.45s onChangeonChangeCall <optional>
日期被点击时的回调函数 dateTimeFormatdateTimeFormatCall <optional>
自定义日历显示格式 disabledDatedisabledDateCall <optional>
更精细的不可选日期控制函数 beforeShowDatebeforeShowDateCall <optional>
个性自定义每日显示样式 minRangeGapnumber <optional>
range时最小选择区间 maxRangeGapnumber <optional>
range时最大选择区间 onRangeGapInvalidrangeGapInvalidCall <optional>
range选择不合minRangeGap与maxRangeGap时回调函数 numberOfMonthsnumber | Array.<number> <optional>
设置一次显示几个月 number 一行显示的月份数 number[] 显示的行数与列数,设置opts.numberOfMonths则默认opts.showOtherMonthDates为false Returns:
- Type
- calendarTag
Example
riot.mount('riot-calendar', opts)
Type Definitions
-
beforeShowDateClass(data当前正在渲染的riot-date对象)
-
beforeShowDate 个性化日期显示
Parameters:
Name Type Description data当前正在渲染的riot-date对象riot-date - Since:
-
- 0.0.3beta1
Returns:
返回个性化后的html片段及类名,如果为string则为html- Type
- date-diy
-
calendarTag
-
扩展Tag实例
Type:
- object
- See:
Properties:
Name Type Description prevMonthfunction 选择前一个月,不能传参数 nextMonthfunction 选择下一个月,不能传参数 getSelectDatesgetSelectDatesCall 返回当前选择日期对象 switchCalendarByDateswitchCalendarByDateCall 跳转到指定日期 -
date-diy
-
Type:
- object | string
Properties:
Name Type Description htmlstring 个性化的日期html片段 classNamestring 个性化的日期类名,多个以空格分隔 -
dateTimeFormatCall(y, m, d)
-
dateTimeFormat 函数说明
Parameters:
Name Type Description ynumber 年份 mnumber 月份 dnumber 天数 -
disabledDateCall(date)
-
disabledDate 不可选日期函数说明
Parameters:
Name Type Description dateriot-date 当前正在渲染的riot-date对象 - Since:
-
- 0.0.2
-
getSelectDatesCall()
-
getSelectDates 函数说明
Returns:
- Type
- selectDateObj
-
onChangeCall(date, tag)
-
onChange 函数说明
Parameters:
Name Type Description dateriot-date 当前被点击riot-date对象 tagcalendarTag 当前riot-calendar实例对象 -
rangeGapInvalidCall(invalidType)
-
onRangeGapInvalid range时选择区间不合minRangeGap与maxRangeGap时回调函数,如果无参数,则默认将rangeEnd变为rangeStart
Parameters:
Name Type Description invalidTypestring 非法类型 'min'或'max' - Since:
-
- 0.0.3beta1
Returns:
是否继续执行将rangeEnd替换成rangeStart- Type
- boolean
-
riot-date
-
Type:
- object
Properties:
Name Type Argument Description currentnumber 表示月份 -1:前一个月 0:当前月 1:后一个月 datedate 当前日期对象 ynumber 年份 mnumber 月份 dnumber 日 wnumber 星期 dateformatstring 日期字符串,可以被opts.dateTimeFormat控制,默认为yyyy-mm-dd rangenumber <optional>
表示范围选择,只有当opts.isRange为true时有效 -1:表示范围开始 0:表示范围中 1:表示范围结束 selectnumber <optional>
表示是否被选中 1:表示选中 disablenumber 表示当前日期是否可用 0:表示可用 1:表示其它月 2:表示超出range范围 3:表示超出min-max范围 -
selectDateObj
-
Type:
- object
Properties:
Name Type Description datesArray.<date> 被选中排序后的Date数组或空数组 dateStrArray.<string> 被选中排序后并经过opts.dateTimeFormat格式化后的日期字符串或空数组 -
switchCalendarByDateCall(需要跳转的日期)
-
switchCalendarByDate 函数说明
Parameters:
Name Type Description 需要跳转的日期date - Since:
-
- 0.0.3beta1
Returns:
跳转是否成功,日期如果超出受限范围[rangeLimit/minDate/maxDate]且switchViewOverLimit=true,则跳转不成功,返回false, 如果跳转日期就是当前日历视图也不会跳转,返回false- Type
- boolean