Skip to content
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

Feature request: Allow to define our own stringify function #229

Closed
skjnldsv opened this issue Jan 15, 2019 · 4 comments
Closed

Feature request: Allow to define our own stringify function #229

skjnldsv opened this issue Jan 15, 2019 · 4 comments

Comments

@skjnldsv
Copy link

Hello and thanks for your awesome component!
Could it be possible to define our own stringify function?
Just to change the display but not the data itself. Recent 2.8.0 added a value2date function, but it's also used in the handleValueChange function and therefore preventing us to use it since it is also completely changing the selected value.

Thanks a lot
Cheers

@mengxiong10
Copy link
Owner

try this.

import DatePicker form 'vue2-datepicker'

DatePicker.methods.stringify = function(date) {}

@skjnldsv
Copy link
Author

skjnldsv commented Jan 15, 2019

@mengxiong10 Thats' what I do for now, but this is really hackish. A nice prop would be better for that I think :)

@mengxiong10
Copy link
Owner

mengxiong10 commented Jan 29, 2019

v2.9.0.

<date-picker v-model="value" lang="en" :format="myFormat"></date-picker>
  data () {
    return {
      myFormat: {
        stringify: (date) => {
          return date ? moment(date).format('LL') : null
        },
        parse: (value) => {
          return value ? moment(value, 'LL').toDate() : null
        }
      }
    }
  }

@skjnldsv
Copy link
Author

You're awesome!! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants