A Vue component that wraps the Flatpickr.
Demo: https://jrainlau.github.io/vue-flatpickr/
npm install vue-flatpickr
Enter one of your .vue file, load the instance VueFlatpickr-en.vue (or VueFlatpickr-zh for Chinese), and the stylesheet flatpickr.min.css.
Note that you have set the correct path, for example you might set the path as
../node_modules/vue-flatpickr/VueFlatpickr-en.vueand so on.
<template>
<vue-flatpickr></vue-flatpickr>
</template>
<script>
import VueFlatpickr from './VueFlatpickr-en'
export default {
components: {
VueFlatpickr
}
}
</script>
<style>
@import './assets/flatpickr.min.css';
</style>
Use props to pass the options object to vue-flatpickr. The options are same to the official document. Here is an example below:
<!-- template -->
<vue-flatpickr :options="fpOptions"></vue-flatpickr>
<!-- script -->
data() {
return {
fpOptions: {
enableTime: true
}
}
}
The <vue-flatpick></vue-flatpickr> tag could be use as a normal <input> tag, which you can use v-model to bind data withVue model:
<vue-flatpickr v-model='date'></vue-flatpickr>
vue-flatpickr supports all the offical themes, all you need to do is to pick up the one you like:
flatpickr.min.cssflatpickr.confetti.min.cssflatpickr.dark.min.cssflatpickr.material_blue.min.cssflatpickr.material_green.min.cssflatpickr.material_orange.min.cssflatpickr.material_red.min.css
MIT