vue-flatpickr——封装了好看又强大的时间选择器 Flatpickr 的 Vue 组件

2,597 阅读1分钟

A Vue component that wraps the Flatpickr.

Demo: jrainlau.github.io/vue-flatpic…

Install

npm install vue-flatpickr

Usage

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.vue and so on.






@import './assets/flatpickr.min.css';

Options

Use props to pass the options object to vue-flatpickr. The options are same to the official document. Here is an example below:





data() {
    return {
      fpOptions: {
        enableTime: true
      }
    }
  }

Data binding

The tag could be use as a normal tag, which you can use v-model to bind data withVue model:


Themes

vue-flatpickr supports all the offical themes, all you need to do is to pick up the one you like:

  • flatpickr.min.css
  • flatpickr.confetti.min.css
  • flatpickr.dark.min.css
  • flatpickr.material_blue.min.css
  • flatpickr.material_green.min.css
  • flatpickr.material_orange.min.css
  • flatpickr.material_red.min.css

Lisense

MIT