Vue2-datepicker: Global options setting

Created on 4 Sep 2018  路  6Comments  路  Source: mengxiong10/vue2-datepicker

Hi!
I use your package as a plugin in my app. Then I need to setup global options for all input after.
But I can't find anything guide me.
Please guide me to make it!
Thanks

All 6 comments

What options do you want to set?
If you want to do something after all change event.
You need to change the code inner.

import DatePicker from 'vue2-datepicker'

DatePicker.methods.updateDate = function() {
  DatePicker.methods.updateDate();
  // do your things
}

Hi! Thank for your reply.
I want to set global language and format date time. In the document, I only can find the setting as props.
I need do it at all my component. I think it a bad way!

Longtime wait for a reply....

import DatePicker from 'vue2-datepicker'

DatePicker.props.format="MM-YYYY"

This works for me:

DatePicker.props.lang.default = process.env.VUE_APP_I18N_LOCALE;//es
DatePicker.props.format.default = Constants.General.DATE_FORMAT;//DD-MM-YYYY
Vue.component('date-picker', DatePicker);

This works for me. I changed a handful of default values globally as I want all of my date inputs to be the same 99% of the time:

DatePicker.props.format.default = "MM/DD/YYYY";
DatePicker.props.editable.default = false;
DatePicker.props.inputClass.default = "form-control";
DatePicker.props.placeholder.default = "Select date";
DatePicker.props.appendToBody.default = false;
DatePicker.props.popupStyle.default = function _default() { return {left: 0}; };
Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaxDiMart picture MaxDiMart  路  5Comments

lequy1010 picture lequy1010  路  5Comments

4spen picture 4spen  路  4Comments

colq2 picture colq2  路  4Comments

burzum picture burzum  路  3Comments