Search code examples
vue.jsvuetify.jsintervalstimepicker

Vuetify, time-picker - how to set allowed time in 15 minutes intervals?


Im new in vuetify. Im trying to set the time in 15 minutes intervals and another options set as disabled. Anyone can help me to find a solution? Code is here:

   v-model="time"
   :allowed-hours="allowedHours"
   :allowed-minutes="allowedMinutes"
   class="mt-4"
   format="24hr"
   scrollable
   min="9:30"
   max="22:15"
 ></v-time-picker>
 <v-time-picker
   v-model="timeStep"
   :allowed-minutes="allowedStep"
   class="mt-4"
   format="24hr"
 ></v-time-picker>


script>
export default {
 data () {
   return {
     time: '11:15',
     timeStep: '10:10',
   }
 },
 methods: {
allowedHours,
   allowedMinutes:,
   allowedStep: ,
 },
}
</script>

Solution

  • You can try this

    <v-time-picker
       v-model="time"
       :allowed-minutes="allowedStep"
       format="24hr"
       scrollable
       min="9:30"
       max="22:15"
    ></v-time-picker>
    

    And you can add the allowedStep method as follows:

    methods: {
      allowedStep: m => m % 15 === 0,
    },