v3-migration-guide icon indicating copy to clipboard operation
v3-migration-guide copied to clipboard

$listeners migration

Open pikax opened this issue 4 years ago • 0 comments

On v3 there's no more $listeners and users might rely on that to handle certain case

// v2
if($listeners['my-event']) {
  // do something
  $listeners['my-event']()
}

In v3 the code can be converted in 2 ways

if($attrs['onMyEvent']) {
  // do something
}
// or 
props: {
  onMyEvent: Function
}
if(props.onMyEvent) {
  // do something
}

I personally think the declaring props is a bit more straight-forward and more explicit

playground

pikax avatar Oct 07 '21 13:10 pikax