I have this component:
<template>
<div>
<label class="col-form-label">
<span>From</span>
</label>
<DatepickerFrom v-on:selected="SetSelectedDateFrom" :value="config.state.fromDate" :disabled="config.disabledFrom"></DatepickerFrom>
</div>
</template>
<script>
import DatepickerFrom from 'vuejs-datepicker'
const dUse = new Date()
export default {
data() {
return {
config: {
disabledFrom: {
to: new Date(dUse.getFullYear() - 1, dUse.getMonth(), dUse.getDate()),
from: new Date(dUse.getFullYear(), dUse.getMonth(), dUse.getDate())
},
state: {
fromDate: new Date(
dUse.getFullYear(),
dUse.getMonth(),
dUse.getDate() - 1
).toString()
}
}
}
},
methods: {
SetSelectedDateFrom: function(selectedDate) {
this.$emit('selected', selectedDate)
}
},
components: {
DatepickerFrom
}
}
</script>
note this part:
:value="config.state.fromDate"
I load this component:
<div class="card selector col-md-4 holder">
<pickerTo v-on:selected="DateSelector2" ></pickerTo>
</div>
import pickerTo from '../components/DateFilterTo'
i have a function that gets the selected value once the a change occurs:
DateSelector2: function(date) {
FromDate = date
}
Once a new date is picked i assign it to a global variable inside of my parent.
Problem:
I have a default date set in the component which I would like to get when I am making a request to the server. I cant figure out how to get this default value since it does not occur within the change event.
I am new to vue.