What I am attempting:
when a button is clicked, a js function passes a value to a vue method and triggers the events attached to the method.
my js file:
function StartDate(){
DatePicker.methods.dateInput(moment(new Date()).format(moment.HTML5_FMT.DATE))
}
window.updateStartDate = updateStartDate;
Button.addEventListener('click', function () {
StartDate()
});
my .vue file :
<template>
<vue-date-picker
v-model="date"
format="DD/MM/YYYY"
@input="dateInput(date)"
@onChange="dateInput(date)"
v-bind:name="name"
>
</vue-date-picker>
</template>
<script>
props: {
name: {
type: String,
default: 'ChangeMe',
},
value: {
type: String,
default: (moment().format(moment.HTML5_FMT.DATE)),
},
},
data: () => ({
date: moment(new Date()).format(moment.HTML5_FMT.DATE),
}),
methods: {
dateInput(value) {
this.$emit('input', value);
this.$emit('change');
}
},
}
</script>
When i console log inside my method I can see i've successfully passed in the date I want however instead of changing the value or triggering an onchange/on input event, I receive this error:
this.$emit is not a function