mengxiong10 / vue2-datepicker

A datepicker / datetimepicker component for Vue2
https://mengxiong10.github.io/vue2-datepicker/index.html
MIT License
1.52k stars 406 forks source link

Support text inputs #141

Closed qkdreyer closed 6 years ago

qkdreyer commented 6 years ago

Would it be possible to support text input ? I could also try to implement it if you could guide me a little

This plugin has implemented it : http://g.recordit.co/9AeBccW1EQ.gif Link : http://blog.w3cub.com/vue2-calendar/

mengxiong10 commented 6 years ago

v2.x supports text input by default. The date will change when the input element triggers event change not input

qkdreyer commented 6 years ago

I didn't manage to use it on your demo page : http://recordit.co/ll71gTGdzj This is using https://unpkg.com/vue2-datepicker@2.4.0/lib/index.js

mengxiong10 commented 6 years ago

Yes, because it set the not-before. so you types a invalid date, it don't change.

qkdreyer commented 6 years ago

Indeed, thanks. Would it be possible to update the popup date while typing ?

mengxiong10 commented 6 years ago

I don't want to change it for now, because it will trigger many unnecessary input event and there will be a lot of invalid time.

qkdreyer commented 6 years ago

Would you accept a PR if this feature is disabled by default ?

mengxiong10 commented 6 years ago

You can easily implement it by modifying the method.

import DatePicker from 'vue2-datepicker'

const handleInput = DatePicker.methods.handleInput

DatePicker.methods.handleInput = function (event) {
  handleInput.call(this, event)
  this.handleChange(event)
  this.showPopup()
}