I'm trying to design a component that select a date range in VueJS. From a specific key ("realtime", "today", "yesterday") that the component get via a props, or changed by the user using a selector, it will returns:
- start/stop date as a JS Date object
- start/stop human representation of the period
- human representation of the key according to the locale.
My conceptual goal is to use a such component like this (invalid syntax, but it is just to explain the issue):
Select your period:
<DateRangeSelector v-model="drskey" ref="drs">
Selected period: {{ drs.periodName }}
Dates: {{ drs.dateStartHuman }} to {{ drs.dateStopHuman }}
Please note that:
- no VueX state (there is no need to store anything here in a global state)
- i don't want to store anything else than the "key" in the "parent" component
- refs doesn't work because they are not initialized at the beginning
Any advices?