UNPKG

9.28 kBMarkdownView Raw
1# @livelybone/vue-datepicker
2[![NPM Version](http://img.shields.io/npm/v/@livelybone/vue-datepicker.svg?style=flat-square)](https://www.npmjs.com/package/@livelybone/vue-datepicker)
3[![Download Month](http://img.shields.io/npm/dm/@livelybone/vue-datepicker.svg?style=flat-square)](https://www.npmjs.com/package/@livelybone/vue-datepicker)
4![gzip with dependencies: 25kb](https://img.shields.io/badge/gzip--with--dependencies-25kb-brightgreen.svg "gzip with dependencies: 25kb")
5![typescript](https://img.shields.io/badge/typescript-supported-blue.svg "typescript")
6![pkg.module](https://img.shields.io/badge/pkg.module-supported-blue.svg "pkg.module")
7
8> `pkg.module supported`, which means that you can apply tree-shaking in you project
9
10[中文文档](./README-CN.md)
11
12A vue component of datepicker, includes DatePicker, DatetimePicker, DateRangePicker, TimePicker
13
14## repository
15https://github.com/livelybone/vue-datepicker.git
16
17## Demo
18https://livelybone.github.io/vue/vue-datepicker/
19
20## Run Example
21Your can see the usage by run the example of the module, here is the step:
22
231. Clone the library `git clone https://github.com/livelybone/vue-datepicker.git`
242. Go to the directory `cd your-module-directory`
253. Install npm dependencies `npm i`(use taobao registry: `npm i --registry=http://registry.npm.taobao.org`)
264. Open service `npm run dev`
275. See the example(usually is `http://127.0.0.1:3000/examples/test.html`) in your browser
28
29## Installation
30```bash
31npm i -S @livelybone/vue-datepicker
32```
33
34## Global name - The variable the module exported in `umd` bundle
35`VueDatepicker`
36
37## Interface
38See what method or params you can use in [index.d.ts](./index.d.ts)
39
40## Usage
41```js
42import { Datepicker, Timepicker, DatetimePicker, DateRangePicker } from '@livelybone/vue-datepicker';
43
44// Global register
45Vue.component('datepicker', Datepicker);
46Vue.component('timepicker', Timepicker);
47Vue.component('datetime-picker', DatetimePicker);
48Vue.component('date-range-picker', DateRangePicker);
49
50// Local register
51new Vue({
52 components:{ Datepicker, Timepicker, DatetimePicker, DateRangePicker }
53})
54```
55
56when you want to set this module as external while you are developing another module, you should import it like this:
57```js
58import * as VueDatepicker from '@livelybone/vue-datepicker'
59
60// then use it by need
61```
62
63Use in html, see what your can use in [CDN: unpkg](https://unpkg.com/@livelybone/vue-datepicker/lib/umd/)
64```html
65<-- use what you want -->
66<script src="https://unpkg.com/@livelybone/vue-datepicker/lib/umd/<--module-->.js"></script>
67```
68
69## Props
70
71### Common
72| Name | Type | DefaultValue | Description |
73| ------------------------- | ----------------------------------------- | -------------------------------------------- | ------------ |
74| `id` | `[String, Number]` | none | |
75| `value` | `[String, Number]` | none | |
76| `placeholder` | `String` | `请选择` | |
77| `min` | `String` | none | Min |
78| `max` | `String` | none | Max |
79| `canEdit` | `Boolean` | `true` | If it can be changed |
80| `inputStyle` | `Object` | none | Style of input tag |
81| `popperProps` | `Object` | `defaultPopperProps` | Props of module [@livelybone/vue-popper](https://github.com/livelybone/vue-popper) |
82| `scrollbarProps` | `Object` | `{ isMobile: false, maxHeight: 200 }` | Props of scrollbar, see [vue-scrollbar-live](https://github.com/livelybone/vue-scrollbar-live) |
83
84```js
85const defaultPopperProps = {
86 arrowPosition: 'start',
87 arrowOffsetScaling: 1,
88 popperOptions: {
89 placement: 'bottom-start',
90 positionFixed: true,
91 // more options in https://popper.js.org
92 },
93}
94```
95
96### Datepicker
97| Name | Type | DefaultValue | Description |
98| ------------------- | ------------ | -------------------------------------------- | ------------ |
99| `dayStr` | `Array` | `['日', '一', '二', '三', '四', '五', '六']` | Used to set day name |
100| `monthStr` | `Array` | `['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']` | Used to set month name |
101| `multiple` | `Boolean` | `false` | |
102| `type` | `String` | `date` | Options: [`year`,`month`,`date`] |
103| `firstDayOfWeek` | `Number` | `0` | Used to set the first day of week. Options: [0, 1, 2, 3, 4, 5, 6] |
104| `btnStr` | `String` | `确定` | Used to set text of button |
105
106### Timepicker
107| Name | Type | DefaultValue | Description |
108| ----------------- | ---------------------- | -------------------------------------------- | ------------ |
109| `type` | `String` | `second` | Options: [`hour`,`minute`,`second`] |
110| `timeStr` | `Array` | `['时', '分', '秒']` | Used to set time name |
111| `btnStr` | `String` | `确定` | Used to set text of button |
112
113### DatetimePicker
114| Name | Type | DefaultValue | Description |
115| ----------------- | ---------------------- | -------------------------------------------- | ------------ |
116| `dayStr` | `Array` | `['日', '一', '二', '三', '四', '五', '六']` | Used to set day name |
117| `monthStr` | `Array` | `['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']` | Used to set month name |
118| `timeStr` | `Array` | `['时', '分', '秒']` | Used to set time name |
119| `btnStr` | `String` | `确定` | Used to set text of button |
120| `firstDayOfWeek` | `Number` | `0` | Used to set the first day of week. Options: [0, 1, 2, 3, 4, 5, 6] |
121| `timeType` | `String` | `second` | Options: [`hour`,`minute`,`second`] |
122
123### DateRangePicker
124| Name | Type | DefaultValue | Description |
125| --------------------- | ---------------------- | -------------------------------------------- | ------------ |
126| `value` | `Array` | `[null, null]` | Used to set day name |
127| `dayStr` | `Array` | `['日', '一', '二', '三', '四', '五', '六']` | Used to set day name |
128| `monthStr` | `Array` | `['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']` | Used to set month name |
129| `btnStr` | `String` | `确定` | Used to set text of button |
130| `firstDayOfWeek` | `Number` | `0` | Used to set the first day of week. Options: [0, 1, 2, 3, 4, 5, 6] |
131| `secondPlaceholder` | `String` | `请选择结束` | |
132| `rangeSeparator` | `String` | `至` | |
133
134## Events
135| Name | EmittedData | Description |
136| --------------------- | --------------------- | ------------------------------------------------- |
137| `input` | `String` | |
138
139## style
140For building style, you may need to import the css or scss file:
141```js
142// scss
143import 'node_modules/@livelybone/vue-datepicker/lib/css/index.scss'
144
145// css
146import 'node_modules/@livelybone/vue-datepicker/lib/css/index.css'
147```
148Or
149```scss
150// scss
151@import 'node_modules/@livelybone/vue-datepicker/lib/css/index.scss'
152
153// css
154@import 'node_modules/@livelybone/vue-datepicker/lib/css/index.css'
155```
156
157Or, you can build your custom style by copying, editing and importing `node_modules/@livelybone/vue-datepicker/lib/css/index.scss`
158
159## QA
160
1611. Error `Error: spawn node-sass ENOENT`
162
163> You may need install node-sass globally, `npm i -g node-sass`