From c8015164f1bf45fb4b1f18a145ef4de4bc951da3 Mon Sep 17 00:00:00 2001 From: mengxiong10 <15623530290@163.com> Date: Tue, 29 Jan 2019 22:30:45 +0800 Subject: [PATCH] feat: support custom format function --- README.md | 2 +- README.zh-CN.md | 2 +- src/index.vue | 74 ++++++++++++++++++++++++++++++------------ src/utils/index.js | 2 +- src/utils/transform.js | 32 ++---------------- test/index.spec.js | 11 +------ test/transform.spec.js | 25 ++++---------- 7 files changed, 66 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 2bce1ec5..016489b9 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ export default { |------|--------------|-------|---------| | type | select date type | 'date' \| 'datetime' \| 'year' \| 'month' \| 'time' | 'date' | | range | if true, the type is daterange or datetimerange | `boolean` | false | -| format | format the Date. The parsing tokens are similar to the moment.js | [token](https://github.com/taylorhakes/fecha#formatting-tokens) | 'YYYY-MM-DD' | +| format | format the Date. The parsing tokens are similar to the moment.js | [token](https://github.com/taylorhakes/fecha#formatting-tokens) \| [`object`](https://github.com/mengxiong10/vue2-datepicker/issues/232#issuecomment-458558141) | 'YYYY-MM-DD' | | value-type | type of binding value. If not specified, the binding value will be a Date object | [value-type](#value-type) | 'date' | | lang | Translation | [lang](#lang) | 'zh' | | clearable | if false, don't show the clear icon | `boolean` | true | diff --git a/README.zh-CN.md b/README.zh-CN.md index 14fa39e4..ccf34077 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -85,7 +85,7 @@ export default { |------|--------------|-------|---------| | type | 选择日期类型 | 'date' \| 'datetime' \| 'year' \| 'month' \| 'time' | 'date' | | range | 如果是true, 显示日历范围选择 | `boolean` | false | -| format | 格式化显示日期, 值类似moment.js | [token](https://github.com/taylorhakes/fecha#formatting-tokens) | 'YYYY-MM-DD' | +| format | 格式化显示日期, 值类似moment.js | [token](https://github.com/taylorhakes/fecha#formatting-tokens) \| [`object`](https://github.com/mengxiong10/vue2-datepicker/issues/232#issuecomment-458558141) | 'YYYY-MM-DD' | | value-type | 设置绑定值的格式, 默认返回日期对象 | [value-type](#value-type) | 'date' | | lang | 选择语言或自定义 | [lang](#lang) | 'zh' | | clearable | 如果设置false, 不显示清除图标 | `boolean` | true | diff --git a/src/index.vue b/src/index.vue index 175ddefa..bb1d70a2 100644 --- a/src/index.vue +++ b/src/index.vue @@ -110,8 +110,8 @@