# uni-datetime-picker ## Instructions 重要通知 组件升级更新 2.0.0 后,支持日期+时间范围选择,组件 ui 将使用日历选择日期,ui 变化较大,同时支持 PC 和 移动端。此版本不向后兼容,不再支持单独的时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)。若仍需使用旧版本,可在插件市场下载 非uni_modules版本 ,旧版本将不再维护 组件名:uni-datetime-picker ### Syntax - 使用 ``(或 ``,当需要包裹子节点时)。 - 遇到平台差异时,建议使用条件编译(`#ifdef / #endif`)显式处理。 #### Properties | 属性名 | 类型 | 默认值 | 值域 | 说明 | | --- | --- | --- | --- | --- | | type | String | datetime | date/daterange/datetime/datetimerange | 选择器类型 | | value | String、Number、Array(范围选择)、Date | - | - | 输入框当前值 | | start | String、Number | - | - | 最小值,可以使用日期的字符串(String)、时间戳(Number) | | end | String、Number | - | - | 最大值,可以使用日期的字符串(String)、时间戳(Number) | | return-type | String | string | timestamp 、string、date | 返回值格式 | | border | Boolean | true | - | 是否有边框 | | rangeSeparator | String | '-' | - | 选择范围时的分隔符 | | placeholder | String | - | - | 非范围选择时的占位内容 | | start-placeholder | String | - | - | 范围选择时开始日期的占位内容 | | end-placeholder | String | - | - | 范围选择时结束日期的占位内容 | | disabled | Boolean | false | - | 是否不可选择 | | clear-icon | Boolean | true | | 是否显示清除按钮 | | hide-second | Boolean | false | - | 是否显示秒,只显示时分 | #### Events | 事件名称 | 说明 | 返回值 | | --- | --- | --- | | change | 确定日期时间时触发的事件,参数为当前选择的日期对象 | 单选返回日期字符串,如:'2010-02-3';范围选返回日期字符串数组,如:['2020-10-1', '2021-4-1'] | | maskClick | 点击遮罩层触发 | - | | show | 弹窗弹出时触发 | - | #### Platform Compatibility See official docs for platform support table: `https://uniapp.dcloud.net.cn/component/uniui/uni-datetime-picker.html` ### Examples ### Example (Example 1) ```vue ``` ### Example (Example 2) ```html ``` ### Example (Example 3) ```vue ``` ### Example (Example 4) ```html ``` ### Example (Example 5) ```html ``` ### Example (Example 6) ```html ``` Reference: - [Official Documentation](https://uniapp.dcloud.net.cn/component/uniui/uni-datetime-picker.html) - [Plugin Marketplace](https://ext.dcloud.net.cn/plugin?name=datetime-picker) - [Local Example](examples/uni-ui/uni-datetime-picker.vue)