Vue Date Pick
Vue Date Pick is a lightweight and mobile-friendly date and time picker component built for Vue.js applications. Currently stable at version 1.5.1, it was last published approximately four years ago, suggesting a maintenance-only status rather than active development. A key differentiator is its explicit lack of external dependencies on CSS frameworks or date manipulation libraries, resulting in a minimal footprint (less than 5KB). It emphasizes performance, an elegant and usable UI across various screen sizes, and straightforward configuration. While its primary target appears to be Vue 2 given its last update date and common usage patterns, it can be integrated using standard Vue component registration methods. The project offers a comprehensive demo and documentation pages for usage and customization.
Common errors
-
[Vue warn]: Unknown custom element: <date-pick> - did you register the component correctly?
cause The `date-pick` component was not registered either globally or locally within the Vue component using it.fixEnsure `DatePick` is imported and added to the `components` option of your Vue component (e.g., `components: { DatePick }`) or globally registered using `Vue.component('date-pick', DatePick);`. -
Picker UI appears unstyled or misaligned, looking like raw HTML elements.
cause The required CSS file for `vue-date-pick` was not imported into the application.fixAdd `import 'vue-date-pick/dist/vueDatePick.css';` to your application's entry file (e.g., `main.js`) or a top-level component. -
Dates displayed or parsed are incorrect or in an unexpected format.
cause The `display-format` prop is either missing, incorrect, or a custom date parser is needed for complex date strings.fixReview the documentation for `display-format` and `custom date parser` options. Ensure the `display-format` prop matches the desired output format, adhering to moment.js-like formatting strings.
Warnings
- gotcha The package was last published four years ago, primarily targeting Vue 2. Using it directly in a Vue 3 project may lead to compatibility issues or require a compatibility build if the project doesn't explicitly support Vue 3.
- gotcha The default styles for `vue-date-pick` are not automatically applied. You must explicitly import the component's CSS file in your application to ensure proper rendering and functionality.
- deprecated The project is in maintenance mode with no recent updates (last publish 4 years ago). This means there will be no new features, and potential bugs or security vulnerabilities might not be addressed.
Install
-
npm install vue-date-pick -
yarn add vue-date-pick -
pnpm add vue-date-pick
Imports
- DatePick
import { DatePick } from 'vue-date-pick';import DatePick from 'vue-date-pick';
- CSS Styles
/* Missing CSS import */
import 'vue-date-pick/dist/vueDatePick.css';
- DatePick (CommonJS)
const DatePick = require('vue-date-pick');const DatePick = require('vue-date-pick').default;
Quickstart
import Vue from 'vue';
import DatePick from 'vue-date-pick';
import 'vue-date-pick/dist/vueDatePick.css';
new Vue({
el: '#app',
components: {
DatePick
},
data: {
selectedDate: new Date().toISOString().substring(0, 10)
},
template: `
<div id="app">
<h1>Vue Date Pick Demo</h1>
<p>Selected Date: {{ selectedDate }}</p>
<date-pick
v-model="selectedDate"
:has-time="true"
:start-date="new Date()"
:display-format="'YYYY-MM-DD HH:mm'"
></date-pick>
</div>
`
});