| | |
| | | |
| | | ## 代码演示 |
| | | |
| | | <a href="https://developers.weixin.qq.com/s/Am6VDimq73SP" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a> |
| | | |
| | | <blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" > |
| | | <p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p> |
| | | </blockquote> |
| | | |
| | | ### 组件类型 |
| | | |
| | | #### 年月日选择器 |
| | |
| | | |
| | | {{ steps }} |
| | | |
| | | #### 不使用 Popup |
| | | |
| | | {{ without-popup }} |
| | | |
| | | ## API |
| | | |
| | | ### DateTimePicker Props |
| | | |
| | | 名称 | 类型 | 默认值 | 说明 | 必传 |
| | | 名称 | 类型 | 默认值 | 描述 | 必传 |
| | | -- | -- | -- | -- | -- |
| | | style | Object | - | 样式 | N |
| | | custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N |
| | | cancel-btn | String | 取消 | 取消按钮文字 | N |
| | | confirm-btn | String | - | 确定按钮文字 | N |
| | | custom-locale | String | zh | 组件国际化语言,目前支持: 简体中文(zh)、(tc)、英文(en)、日语(ja)、韩语(ko)、俄语(ru)等六种语言 | N |
| | | end | String / Number | - | 选择器的最大可选时间,默认为当前时间+10年 | N |
| | | external-classes | Array | - | 组件类名,分别用于设置组件外层元素、确认按钮、取消按钮、标题等元素类名。`['t-class', 't-class-confirm', 't-class-cancel', 't-class-title']` | N |
| | | footer | Slot | - | 底部内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N |
| | | format | String | 'YYYY-MM-DD HH:mm:ss' | 用于格式化 pick、change、confirm 事件返回的值,[详细文档](https://day.js.org/docs/en/display/format) | N |
| | | header | Boolean / Slot | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N |
| | | mode | String / Array | 'date' | year = 年;month = 年月;date = 年月日;hour = 年月日时; minute = 年月日时分;当类型为数组时,第一个值控制年月日,第二个值控制时分秒。TS 类型:`DateTimePickerMode` `type DateTimePickerMode = TimeModeValues \| Array<TimeModeValues> ` `type TimeModeValues = 'year' \| 'month' \| 'date' \| 'hour' \| 'minute' \| 'second'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N |
| | | popup-props | Object | {} | 透传 `Popup` 组件全部属性。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N |
| | | show-week | Boolean | false | 【开发中】是否在日期旁边显示周几(如周一,周二,周日等) | N |
| | | start | String / Number | - | 选择器的最小可选时间,默认为当前时间-10年 | N |
| | | steps | Object | - | 时间间隔步数,示例:`{ minute: 5 }` | N |
| | | title | String | - | 标题 | N |
| | | use-popup | Boolean | true | 是否使用弹出层包裹 | N |
| | | value | String / Number | - | 选中值。TS 类型:`DateValue` `type DateValue = string \| number`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N |
| | | default-value | String / Number | undefined | 选中值。非受控属性。TS 类型:`DateValue` `type DateValue = string \| number`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N |
| | | visible | Boolean | false | 是否显示 | N |
| | |
| | | -- | -- | -- |
| | | cancel | \- | 取消按钮点击时触发 |
| | | change | `(value: DateValue)` | 确认按钮点击时触发 |
| | | close | `(trigger: TriggerSource)` | `1.0.1`。关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts)。<br/>`type TriggerSource = 'overlay' \| 'cancel-btn' \| 'confrim-btn'`<br/> |
| | | close | `(trigger: TriggerSource)` | `1.0.1`。关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts)。<br/>`type TriggerSource = 'overlay' \| 'cancel-btn' \| 'confirm-btn'`<br/> |
| | | confirm | `(value: DateValue)` | `1.0.1`。确认按钮点击时触发 |
| | | pick | `(value: DateValue)` | 选中值发生变化时触发 |
| | | ### DateTimePicker External Classes |
| | | |
| | | 类名 | 描述 |
| | | -- | -- |
| | | t-class | 根节点样式类 |
| | | t-class-cancel | 取消样式类 |
| | | t-class-confirm | 确认样式类 |
| | | t-class-title | 标题样式类 |
| | | |
| | | ### DateTimePicker 组件国际化 |
| | | 组件支持国际化,目前支持:简体中文(zh)、(tc)、英文(en)、日语(ja)、韩语(ko)、俄语(ru)等六种语言,默认为简体中文(zh)。使用方式如下: |
| | | - 全局设置语言: 在小程序全局入口设置 `dayjs` 的语言即可,示例: |
| | | ```js |
| | | import dayjs from 'dayjs'; |
| | | import 'dayjs/locale/zh-cn'; |
| | | |
| | | dayjs.locale('zh-cn'); // 全局设置为简体中文 |
| | | ``` |
| | | - 单个组件设置:在组件上添加 custom-locale 属性即可,注意:custom-locale 优先级高于全局设置。 |
| | | |
| | | ### CSS Variables |
| | | |
| | | 组件提供了下列 CSS 变量,可用于自定义样式。 |
| | | 名称 | 默认值 | 描述 |
| | | -- | -- | -- |
| | | --td-data-time-picker-year-width | 128rpx | - |