0
votes

I have implemented the vue datepicker component as shown in the link below: https://github.com/ReproNim/reproschema-ui/blob/master/src/components/Inputs/YearInput/YearInput.vue

when this component is answered and i move to a different page and revisit this page where the datepicker is, the value gets modified to "1969". in the mounted method (line 53 in above link), i check for any initialized value. if present, it is assigned to data "input". i checked the init value and it is correct (it has the previously answered value) but on screen the component shows "1969".

can someone help as to why this happens?

2
That's probably the default (null) date. The unix epoch date is Jan 1, 1970 (GMT). In the USA, that would be Dec 31 1969.Mike67
yes. how can i get my expected output instead of default? and why does the default appear?Ann

2 Answers

0
votes

The code looks correct for the most part.

Perhaps the input value is not formatted correcty so the default of 'epoch' is used.

Or your typos are causing the problem...

lang=selected_language and :initialView=inputType and :minimumView=inputType


    <datepicker placeholder="Select Date" v-model="input" :lang='selected_language'
                :disabledDates="dateParam.disabledDates" :format="customFormatter"
                :minimumView='inputType' :maximumView="'year'" :initialView='inputType'
                ></datepicker>

0
votes

I finally was able to solve this question!

when the answered value is "year", eg. 1990, in the mounted lifecycle hook, before assigning it to the data variable, I need to convert the 'year' value to a date object.