|
| 1 | +# Getting Started |
| 2 | + |
| 3 | +This guide will help you get started with using `vue3-datepick` in your project. |
| 4 | + |
| 5 | +## Basic Usage |
| 6 | + |
| 7 | +To use `vue3-datepick`, start by installing the package and adding it to your component. |
| 8 | + |
| 9 | +```vue |
| 10 | +<template> |
| 11 | + <DatePicker v-model="selectedDate" /> |
| 12 | +</template> |
| 13 | +
|
| 14 | +<script setup lang="ts"> |
| 15 | +import { ref } from 'vue' |
| 16 | +import DatePicker from 'vue3-datepick' |
| 17 | +
|
| 18 | +const selectedDate = ref('') |
| 19 | +</script> |
| 20 | +``` |
| 21 | + |
| 22 | +In this example, the selected date is bound to the `selectedDate` variable using `v-model`. You can now use this variable elsewhere in your application. |
| 23 | + |
| 24 | +## Customizing the Date Format |
| 25 | + |
| 26 | +You can easily change the format of the date displayed in the input by using the `displayFormat` prop. |
| 27 | + |
| 28 | +Example: Set the date format to `MM/DD/YYYY`: |
| 29 | + |
| 30 | +```vue |
| 31 | +<template> |
| 32 | + <DatePicker v-model="selectedDate" display-format="MM/DD/YYYY" /> |
| 33 | +</template> |
| 34 | +
|
| 35 | +<script setup lang="ts"> |
| 36 | +import { ref } from 'vue' |
| 37 | +
|
| 38 | +const selectedDate = ref('') |
| 39 | +</script> |
| 40 | +``` |
| 41 | + |
| 42 | +## Disabling Specific Dates |
| 43 | + |
| 44 | +You can disable specific dates using the `isDateDisabled` prop. The following example disables Sundays: |
| 45 | + |
| 46 | +```vue |
| 47 | +<template> |
| 48 | + <DatePicker v-model="selectedDate" :is-date-disabled="isDateDisabled" /> |
| 49 | +</template> |
| 50 | +
|
| 51 | +<script setup lang="ts"> |
| 52 | +import { ref } from 'vue' |
| 53 | +
|
| 54 | +const selectedDate = ref('') |
| 55 | +const isDateDisabled = (date: Date) => { |
| 56 | + return date.getDay() === 0 // Disable Sundays |
| 57 | +} |
| 58 | +</script> |
| 59 | +``` |
| 60 | + |
| 61 | +## Customizing Month and Weekday Names |
| 62 | + |
| 63 | +You can customize the names of months and weekdays by passing arrays to the `months` and `weekdays` props. |
| 64 | + |
| 65 | +Example: |
| 66 | + |
| 67 | +```vue |
| 68 | +<template> |
| 69 | + <DatePicker v-model="selectedDate" :months="months" :weekdays="weekdays" /> |
| 70 | +</template> |
| 71 | +
|
| 72 | +<script setup lang="ts"> |
| 73 | +import { ref } from 'vue' |
| 74 | +
|
| 75 | +const selectedDate = ref('') |
| 76 | +const months = ref([ |
| 77 | + 'January', |
| 78 | + 'February', |
| 79 | + 'March', |
| 80 | + 'April', |
| 81 | + 'May', |
| 82 | + 'June', |
| 83 | + 'July', |
| 84 | + 'August', |
| 85 | + 'September', |
| 86 | + 'October', |
| 87 | + 'November', |
| 88 | + 'December', |
| 89 | +]) |
| 90 | +const weekdays = ref(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']) |
| 91 | +</script> |
| 92 | +``` |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +With these examples, you should be able to quickly integrate `vue3-datepick` into your project and customize it according to your needs. |
0 commit comments