1.2.5 • Published 7 months ago

datepicker-pro-vue v1.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

version minizipped minified

Release last-commit MIT License npm.io

一个轻量、界面简洁、直观、功能齐全的日期选择器。支持多语言、农历展示和各种日期格式。

特性

  • 遵循的是 ISO 8601 时间格式标准。
  • 支持预设时间快捷选择。
  • 提供农历/节假日的显示,可自定义假日信息。
  • 组件提供了众多属性方便灵活配置,覆盖了绝大部份的时间业务场景。
  • 界面简洁美观、交互流畅。

快速上手

安装

npm

npm install datepicker-pro-vue

yarn

yarn add datepicker-pro-vue

CDN

// jsdelivr
<script src="https://cdn.jsdelivr.net/npm/datepicker-pro-vue"></script>

// unpkg
<script src="https://unpkg.com/datepicker-pro-vue"></script>

需要引入指定版本时只需在包名后面加入具体版本信息即可。datepicker-pro-vue@xxx,不加默认为最新版

引入

全局注册

import Vue from "vue";
import App from "./App.vue";
import DatePickerPro from 'datepicker-pro-vue'; // 引入组件

Vue.use(DatePickerPro)
// DatePickerPro.install(Vue);

new Vue({
  render: h => h(App),
}).$mount('#app')

使用

<DatePickerPro v-model="value" showTime></DatePickerPro>

效果: image.png

使用

API

Props

参数名描述类型默认值
v-model面板显示的日期Date string number-
allow-clear是否允许清除booleantrue
readonly是否为只读booleanfalse
disabled是否为禁用booleanfalse
disabled-date不可选取的日期(current?: Date) => boolean-
disabled-time不可选取的时间(current: Date) => DisabledTimeProps-
default-picker-value面板默认显示的日期Date string number-
error是否为错误状态booleanfalse
shortcuts预设时间范围快捷选择ShortcutType[][]
position弹出的框的位置top bottomleft righttop-starttop-endbottom-start bottom-endright-startright-endleft-startleft-endbottom
trigger触发方式toggle click hover focus click
popupTag容器标签Stringdiv
showArrow是否显示箭头booleanfalse
offset偏移量String number4
mouseEnterDelay移入事件延迟触发时间number100
mouseLeaveDelay移出事件延迟触发时间number100
forceShow持续展示booleanfalse
renderToBody是否挂载在body下booleanfalse
unmountOnClose是否在隐藏的时候销毁DOM结构booleanfalse
popupContainer弹出框的挂载容器string HTMLElement null undefined-
gpuAcceleration开启GPU加速渲染(低端机可能无法开启)booleantrue
stopPropagation阻止弹窗事件冒泡booleanfalse
preventDefault阻止弹窗默认行为booleanfalse
value-format值的格式,对 value defaultValue pickerValue defaultPickerValue 以及事件中的返回值生效,支持设置为时间戳,Date 和字符串(参考字符串解析格式)。如果没有指定,将格式化为字符串,格式同 formattimestamp Date string-
preview-shortcut是否要预览快捷选择的结果booleantrue
show-confirm-btn是否显示确认按钮,showTime = true 的时候始终显示。booleanfalse

Common Events

事件名描述参数
change组件值发生改变value: Date \| string \| number \| undefineddate: Date \| undefineddateString: string \| undefined
select选中日期发生改变但组件值未改变value: Date \| string \| numberdate: DatedateString: string
popup-visible-change打开或关闭弹出框visible: boolean
ok点击确认按钮value: Date \| string \| numberdate: DatedateString: string
clear点击清除按钮-
select-shortcut点击快捷选项shortcut: ShortcutType
picker-value-change面板日期改变value: Date \| string \| numberdate: DatedateString: string

字符串解析格式

格式输出描述
YY21两位数的年份
YYYY2021四位数年份
M1-12月份,从 1 开始
MM01-12月份,两位数
MMMJan-Dec缩写的月份名称
MMMMJanuary-December完整的月份名称
D1-31月份里的一天
DD01-31月份里的一天,两位数
d0-6一周中的一天,星期天是 0
ddSu-Sa最简写的一周中一天的名称
dddSun-Sat简写的一周中一天的名称
ddddSunday-Saturday一周中一天的名称
H0-23小时
HH00-23小时,两位数
h1-12小时, 12 小时制
hh01-12小时, 12 小时制, 两位数
m0-59分钟
mm00-59分钟,两位数
s0-59
ss00-59秒,两位数
S0-9数百毫秒,一位数
SS00-99几十毫秒,两位数
SSS000-999毫秒,三位数字
Z-5:00UTC 的偏移量
ZZ-0500UTC 的偏移量,数字前面加上 0
AAM PM-
aam pm-
Do1st... 3st带序号的月份中的某天
X1410715640.579Unix 时间戳
x1410715640579Unix 毫秒时间戳

相关依赖

名称版本作者
dayjs^1.11.7iamkun
@popperjs/core^2.11.6floating-ui
b-tween^0.3.3PengJiyuan

参与贡献

贡献之前请先阅读 行为准则

感谢本项目中所有用到的资源、工具的开发们,以及参与贡献的人!

License

本项目使用 MIT 协议许可证。

1.2.5

7 months ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago