[Vuejs]-How to emit a value in composition API

2👍

You need to pass emit, along props to setup:

setup(props, { emit }) {

function emitDate(){
  emit('chosenDate', datepickerValue.value)
}

1👍

The 1st parameter to setup is props. context comes after setup, see setup arguments:

setup(props, context){
....
 function emitDate(){
   context.emit('chosenDate', datepickerValue.value)
 }
}

Or:

setup(props, { emit }){
....
 function emitDate(){
   emit('chosenDate', datepickerValue.value)
 }
}
👤Psidom

Leave a comment