Last active
October 19, 2021 10:49
-
-
Save skushnerchuk/65bfd84cb01b3d04219a0771a28c1ab8 to your computer and use it in GitHub Desktop.
Quasar v2 month picker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <q-input | |
| square | |
| dense | |
| mask="##.####" | |
| outlined | |
| v-bind="$attrs" | |
| :model-value="modelValue" | |
| @update:model-value="setInputValue" | |
| style="width: 125px" | |
| > | |
| <template v-slot:append> | |
| <q-icon class="cursor-pointer" name="las la-calendar" @click.stop> | |
| <q-popup-proxy ref="datePicker" transition-hide="scale" transition-show="scale"> | |
| <q-date | |
| ref="calendar" | |
| no-unset | |
| square | |
| emit-immediately | |
| years-in-month-view | |
| default-view="Months" | |
| @update:model-value="setValue" | |
| mask="MM.YYYY" | |
| minimal | |
| :model-value="modelValue"/> | |
| </q-popup-proxy> | |
| </q-icon> | |
| </template> | |
| </q-input> | |
| </template> | |
| <script> | |
| export default { | |
| name: 'MonthPicker', | |
| methods: { | |
| setValue (value, reason) { | |
| if (reason === 'year') { | |
| this.$refs.calendar.setView('Months') | |
| } else if (reason === 'month') { | |
| this.$emit('update:modelValue', value) | |
| this.$refs.datePicker.hide() | |
| } | |
| }, | |
| setInputValue (value) { | |
| this.$emit('update:modelValue', value) | |
| } | |
| }, | |
| props: { | |
| modelValue: { | |
| type: String | |
| } | |
| }, | |
| emits: ['update:modelValue'] | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment