[Vuejs]-@dayclick does nothing in v-date-picker

0👍

@dayclick="onDayClick" attempts to register an event listener on the <input> for an event named "dayclick", but there’s no such event for HTMLInputElement.

It looks like you’re really trying to listen to VCalendar‘s dayclick event, so the event listener should be on <v-date-picker> instead of <input>:

<!--
<v-date-picker>
  <template>
    <input @dayclick="onDayClick">
           ^^^^^^^^^^^^^^^^^^^^^^ ❌
-->

<v-date-picker @dayclick="onDayClick">
  <template>
    <input>

Your dayclick handler could emit the selected date to the parent component with $emit:

export default {
  methods: {
    onDayClick(date) {
      this.$emit("date-selected", date); 👈
    },
  },
};

demo

Leave a comment