Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue2-datepicker

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue2-datepicker

A Datepicker Component For Vue2

  • 2.12.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
83K
decreased by-0.35%
Maintainers
1
Weekly downloads
 
Created
Source

vue2-datepicker

中文版

A Datepicker Component For Vue2

build:passed Badge npm MIT

Demo

https://mengxiong10.github.io/vue2-datepicker/demo/index.html

image

Install

$ npm install vue2-datepicker --save

Usage

<script>
import DatePicker from 'vue2-datepicker'

export default {
  components: { DatePicker },
  data() {
    return {
      time1: '',
      time2: '',
      time3: '',
      // custom lang
      lang: {
        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'
        }
      },
      // custom range shortcuts
      shortcuts: [
        {
          text: 'Today',
          onClick: () => {
            this.time3 = [ new Date(), new Date() ]
          }
        }
      ],
      timePickerOptions:{
        start: '00:00',
        step: '00:30',
        end: '23:30'
      }
    }
  }
}
</script>

<template>
  <div>
    <date-picker v-model="time1" valueType="format" :first-day-of-week="1"></date-picker>
    <date-picker v-model="time2" type="datetime" :time-picker-options="timePickerOptions"></date-picker>
    <date-picker v-model="time3" range :shortcuts="shortcuts"></date-picker>
    <date-picker v-model="value" :lang="lang"></date-picker>
  </div>
</template>

Props

PropDescriptionTypeDefault
typeselect date type'date' | 'datetime' | 'year' | 'month' | 'time''date'
rangeif true, the type is daterange or datetimerangebooleanfalse
formatformat the Date. The parsing tokens are similar to the moment.jstoken | object'YYYY-MM-DD'
value-typetype of binding value. If not specified, the binding value will be a Date objectvalue-type'date'
langTranslationlang'zh'
clearableif false, don't show the clear iconbooleantrue
confirmif true, need click the button to change the valuebooleanfalse
editableif false, user cann't type itbooleantrue
disabledDisable the componentbooleanfalse
placeholderinput placeholder textstring
widthinput sizestring|number210
append-to-bodyappend the popup to bodybooleanfalse
default-valuedefault date of the calendarDatenew Date()
popupStylepopup style(override the top, left style)object
not-beforeDisable all dates before new Date(not-before)string|Date''
not-afterDisable all dates after new Date(not-after)string|Date''
disabled-daysDisable Days(date) => boolean-
shortcutsthe shortcuts for the range pickershortcutstrue
time-picker-optionscustom time-pickertime-picker-optionsnull
time-select-optionscustom time-selecttime-select-optionsnull
minute-stepif > 0 don't show the second picker0 - 600
first-day-of-weekset the first day of week1 - 77
input-classthe input class namestring'mx-input'
input-attrthe input attr(eg: { required: true, id: 'input'})object
confirm-textthe default text to display on confirm buttonstring'OK'
range-separatorthe range separator textstring'~'
date-formatformat the time header and tooltipstring''
value-type

set the format of binding value

ValueDescription
datebinding value will be a Date object
timestampbinding value will be a timestamp number
formatbinding value will be the format string

Advanced: You can also customize objects to implement two functions.

{
  value2date: (value: any) => Date,  // transform the binding value to calendar Date Object
  date2value: (date: Date) => any   // transform the calendar Date Object to binding value
}

lang
Type
'en'|'zh'|'es'|'pt-br'|'fr'|'ru'|'de'|'it'|'cs'
{ days: string[]; months: string[]; picker: string[]; placeholder: { date: string; dateRange: string } }
shortcuts

the shortcuts for the range picker

ValueDescription
trueshow the default shortcuts
falsehide the defaualt shortcuts
[{text: string, onClick: () => any }]custom shortcuts
time-picker-options

custom time-picker

Type
{start: '00:00', step:'00:30' , end: '23:30'}
() => Array<{ label: string; values: { hours: number; minutes: number } }>
time-select-options

custom time-select for columns

Type
{hours: [9, 10, 11], minutes: [10, 20], seconds: [10, 20] }

Events

NameDescriptionCallback Arguments
inputWhen the value change(v-model event)the currentValue
changeWhen the value change(same as input)the currentValue
confirmWhen click 'confirm' buttonthe currentValue
clearWhen click 'clear' button
input-errorWhen user type a invalid Datethe input text
panel-changeWhen change the panel view(eg: from year to month view)panel, oldPanel
calendar-changeWhen calendar view year or month changenow(Date), oldNow(Date)
focusWhen input focus
blurWhen input blur
panel
ValueDescription
NONEwhen panel is closed
DATEwhen panel is date
YEARwhen panel is year
MONTHwhen panel is month
TIMEwhen panel is time

Slots

NameDescription
calendar-iconcustom the calender icon
headerpopup header
footerpopup footer

ChangeLog

CHANGELOG

Donate

If you find this project useful, you can buy author a glass of juice

PayPal | AliPay | WeChat

License

MIT

Copyright (c) 2017-present xiemengxiong

Keywords

FAQs

Package last updated on 25 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc