2.0.1 • Published 3 years ago

datepicker-vue2-recent v2.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

vue2-datepicker

A Datepicker Component For Vue2

Forked from vue2-datepicker

Improved Features

  • Masking is done from the format given.
  • By Default Picker will open in Current Month. This can be changed with 'defaultDate' prop.

Demo

image

Install

$ npm install vue2datepicker-new --save

Usage

<script>
import DatePicker from 'vue2datepicker-new'

export default {
  components: { DatePicker },
  data() {
    return {
      time1: '',
      time2: '',
      shortcuts: [
        {
          text: 'Today',
          start: new Date(),
          end: new Date()
        }
      ]
    }
  }
}

</script>

<template>
  <div>
    <date-picker v-model="time1" :first-day-of-week="1"></date-picker>
    <date-picker v-model="time2" range :shortcuts="shortcuts"></date-picker>
  </div>
</template>

Attributes

PropTypeDefaultDescription
typeString'date'select datepicker or datetimepicker(date/datetime)
rangeBooleanfalseif true, the type is daterange or datetimerange
formatStringyyyy-MM-ddDate formatting string
custom-formatterfunctionnullcustom Date display
langString/ObjectzhTranslation (en/zh/es/pt-br/fr/ru/de/it/cs)(custom)
confirmBooleanfalseif true, need click the button to change the value
disabledBooleanfalseDisable the component
editableBooleanfalseif true, user can type it(only the range is false)
placeholderStringinput placeholder text
widthString/Number210input size
disabled-daysArray[]Days in YYYY-MM-DD format to disable
not-beforeString/Date''Disable all dates before new Date(not-before)
not-afterString/Date''Disable all dates after new Date(not-after)
shortcutsBoolean/Arraytruethe shortcuts for the range picker
time-picker-optionsObject{}set timePickerOptions(start, step, end)
minute-stepNumber0if > 0 don't show the second picker(0 - 60)
first-day-of-weekNumber7set the first day of week (1-7)
input-classString'mx-input'the input class name
confirm-textString'OK'the default text to display on confirm button
range-separatorString'~'the range separator text
defaultDateDatenew Date()if given, then picker will open in the respective date's month.

lang

  • String (en/zh/es/pt-br/fr/ru/de/it/cs)
  • Object
{
  days: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  pickers: ['next 7 days', 'next 30 days', 'previous 7 days', 'previous 30 days'],
  placeholder: {
    date: 'Select Date',
    dateRange: 'Select Date Range'
  }
}

shortcuts

  • true - show the default shortcuts
  • false - hide the shortcuts
  • Object[] - custom shortcuts, {text, start, end}
PropTypeDescription
textStringText
startDateStart Date
endDateEnd Date

time-picker-options

PropTypeDescription
startStringstartTime (eg '00:00')
stepStringstepTime (eg '00:30')
endStringendTime (eg '23:30')

Events

NameDescriptionCallback Arguments
changeWhen user select datethe currentValue
confirmWhen user click 'OK' buttonthe currentValue

License

MIT

Copyright (c) 2017-present xiemengxiong