[Vuejs]-Fire event when $emit is complete

3👍

in a parent component:

@back-to-parent="onBackToParent"
...
methods: {
  onBackToParent({ data, done }) {
    // process data
    if (done) {
      done()
    }
  }
}

in a child component:

clickevent(data){
           this.$emit('back-to-parent', {data, done: () => { 
                 alert('done') 
             } });
       }

Leave a comment