A simple clean date & time selector library to create date pickers, time pickers, and datetime pickers on the Vue.js app.
# NPM
$ npm install @livelybone/vue-datepicker --save
// import modules
import {Datepicker, Timepicker, DatetimePicker} from '@livelybone/vue-datepicker';
// or
import * as VueDatepicker from '@livelybone/vue-datepicker';
// Globally
Vue.component('datepicker', Datepicker);
Vue.component('timepicker', Timepicker);
Vue.component('datetime-picker', DatetimePicker);
// Locally
new Vue({
components:{Datepicker, Timepicker, DatetimePicker}
})
new Vue({
el: '#datepicker',
template: '<datepicker :value="date" @input="log" min="2018-6-1" max="2020-01-01" :dayStr="dayStr" :popperProps="popperProps" :scrollbarProps="{isMobile:isM}"/>',
data: function () {
return {
dayStr: ['7', '1', '2', '3', '4', '5', '6'],
date: '2018-06-01',
popperProps: popperProps,
}
},
methods: {
log: function (val) {
this.date = val
console.log(val)
},
},
components: { 'datepicker': VueDatepicker.Datepicker },
})
new Vue({
el: '#timepicker',
template: '<timepicker :value="time" @input="log" min="02:10:02" max="22:10:00" :timeStr="timeStr" :scrollbarProps="{isMobile:isM}" :popperProps="popperProps"/>',
data: function () {
return {
timeStr: ['hour', 'min', 'sec'],
time: '03:02:01',
isM: isM,
popperProps: popperProps,
}
},
methods: {
log: function (val) {
this.time = val
console.log(val)
},
},
components: { 'timepicker': VueDatepicker.Timepicker },
})
new Vue({
el: '#datetime-picker',
template: '<datetime-picker :value="time" @input="log" min="2018-08-24 02:10:02" max="2020-09-1 22:10:00" :timeStr="timeStr" :scrollbarProps="{isMobile:isM}" :popperProps="popperProps"/>',
data: function () {
console.log('datetime-picker')
return {
timeStr: ['hour', 'min', 'sec'],
time: '2019-02-01 01:02:01',
isM: isM,
popperProps: popperProps,
}
},
methods: {
log: function (val) {
this.time = val
console.log(val)
},
},
components: { 'datetime-picker': VueDatepicker.DatetimePicker },
})
Author: livelybone
Live Demo: https://livelybone.github.io/vue/vue-datepicker/
Download Link: https://github.com/livelybone/vue-datepicker/archive/master.zip
Official Website: https://github.com/livelybone/vue-datepicker
#vuejs #javascript #vue-js