nathanreyes / v-calendar

An elegant calendar and datepicker plugin for Vue.
https://vcalendar.io
MIT License
4.32k stars 840 forks source link

Have user select only range end date? #1337

Open roman3000 opened 1 year ago

roman3000 commented 1 year ago

Hi, does anyone know how I can set the start date of a range automatically, and have the user only input the end date? I have tried const range = ref({ start: new Date(2023, 1, 24), end: null }); but that's not doing anything.

Has anyone had a similar issue? Thanks

joelpro2 commented 1 year ago

try setting end: undefined

roman3000 commented 1 year ago

Hi, thanks for the suggestion but it didn't work for me.

This is the only thing I could do to get close to what I wanted.

<VDatePicker
  :key="datePickerKey"
  is-expanded
  :columns="columns"
  :expanded="true"
  v-model.range="range"
  :min-date="minDate"
  :firstDayOfWeek="2"
  @click="setDates"
>
</VDatePicker>

const datePickerKey = ref(0); const range = ref({ start: null, end: null });

function setDates(params) { range.value.start = minDate.value; range.value.end = new Date(params.target.ariaLabel); datePickerKey.value++; }