1.1.1 • Published 5 years ago

web-calendar-js v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

web-calendar-js

一个js日历插件(A js calendar plugin )


中文文档

注意事项

  • 兼容 IE8+ (不包括IE8)
  • 本日历插件年份范围在1900年—— 2100年

安装

1. 第一种方式,直接引入

  • 引入js
<script src="https://webxiaoma.github.io/web-calendar-js/lib/js/calendar.min.js"></script>
  • 引入css
<link rel="stylesheet" href="https://webxiaoma.github.io/web-calendar-js/lib/static/css/calendar.min.css">

推荐下载到本地使用,在 web-calendar-js 中 的 lib目录中引入相应的js以及css

2. 第二种方式

使用安装npm下载

npm install --save-dev web-calendar-js

或

npm i -D web-calendar-js

基本用法

var cal = new Calendar(el,options)
  • el: input元素的idclass,推荐使用id
  • options: 日历插件的配置,各项配置见下表;

Options 属性

属性说明类型可选值默认值
format年月日之间的分隔符String——-
isFillZero单月份和单日前是否补0Boolean——true
max可选择的最大时间String/Number时间格式如(2019-2-1、2019/2/1、时间戳)true
min可选择的最小时间String/Number时间格式如(2019-2-1、2019/2/1、时间戳)true
nextMonthBtnText上一年按钮文本String——<<
nextYearBtnName下一年按钮文本String——>>
prevMonthBtnName上一月按钮文本String——<
nextMonthBtnName下一月按钮文本String——>
isHoliday是否在周六周日时显示休息字眼Boolean——true
isLunar是否显示阴历Boolean——true
isFestival是否显示节日(当显示阴历时,才会起作用)Boolean——true
isSolarTerm是否显示节气(当显示阴历时,才会起作用)Boolean——true

Options 事件

事件说明回调参数
click选择日期时触发返回日期对象day,日期对象中含有日期信息dayMsg
change日期更改时触发返回包含年月日等信息的对象
rightHandClick右击日期时触发返回日期对象day

Options 方法

方法说明参数
beforeCreateDay日期天数创建前钩子函数返回日期对象day
afterCreateDay日期天数创建后钩子函数返回日期对象day

其它对象说明

dayMsg对象

  • Animal: 当年的生肖属性
  • IDayCn: "二十"
  • IMonthCn: "十月"
  • LFtv: 阴历常见节日(默认null)
  • SFtv: 阳历历常见节日(默认null)
  • Term: 二十四节气
  • astro: 当日星座
  • cDay: 阳历日
  • cMonth: 阳历月份(1-12)
  • cYear: 阳历年份
  • gzDay: 干支纪天
  • gzMonth: 干支纪月
  • gzYear: 干支纪年
  • isLeap: 是否是闰年,boolean值
  • isTerm: 当时是否是二十四节气,boolean值
  • isToday: 当前阳历日期是否就是今日,boolean值
  • lDay: 阴历号
  • lMonth: 阴历月份
  • lYear: 阴历年份
  • nWeek: 数字星期(1-7)
  • ncWeek: 字符串星期