Skip to content

DatePicker 绑定字符串类型的时间格式 #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
hylarucoder opened this issue Apr 20, 2019 · 7 comments
Closed
1 task

DatePicker 绑定字符串类型的时间格式 #718

hylarucoder opened this issue Apr 20, 2019 · 7 comments

Comments

@hylarucoder
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

希望可以在Value上直接使用字符串格式的日期,

在现有的API基础上, 如果我要达到这个效果. 就必须要先包一层

<template>
    <date-picker
            v-model="value"
    >

    </date-picker>
</template>

<script>
  import { DatePicker } from 'ant-design-vue'
  import moment from 'moment'

  export default {
    name: 'IDatePicker',
    components: {
      DatePicker,
    },
    watch: {
      value: function (val) {
        let value = moment(val).format('YYYY-MM-DD');
        this.$emit('update:value', value)
      },
    },
    data() {
      return {
        value: null,
      }
    },
  }
</script>

在外面这么用

<a-form-item label="创建日期">
<i-date-picker
:value.sync="params.created_at__date"
style="width: 100%"

/>
</a-form-item>

然后取出来的 created_at__date 为 “2018-09-01”

elementui 也有类似实现 https://element.eleme.io/#/zh-CN/component/datetime-picker#attributes

What does the proposed API look like?

<a-form-item label="创建日期">
<i-date-picker
:value.sync="params.created_at__date"
style="width: 100%"
value_format="YYYY-MM-DD" # 如果没有指定 value_format 则使用的是 momentjs 的时间
/>
</a-form-item>
@duyngha
Copy link

duyngha commented Oct 14, 2019

I got the same issue with the value formating. Any updates?

@hjianjie
Copy link

我也遇到同样的问题,是否可以直接支持绑定字符串

@webjipeng
Copy link

同样的问题,我需要直接string的类型,不要monent的

@iisquare
Copy link

一样的痛点,打算自定义个组件,先抗着😂看这issue的处理速度,等不上了

@kevinZhang035
Copy link

不能再同意

@liamwang
Copy link

Table 和 DatePicker 这两个组件远不如 element-ui 方便

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants