$listeners
removed
breaking
Overview
The
$listeners
object has been removed in Vue 3. Event listeners are now part of
$attrs
:
2.x Syntax
In Vue 2, you can access attributes passed to your components with
this.$attrs
, and event listeners with
this.$listeners
. In combination with
inheritAttrs: false
, they allow the developer to apply these attributes and listeners to some other element instead of the root element:
3.x Syntax
In Vue 3's virtual DOM, event listeners are now just attributes, prefixed with
on
, and as such are part of the
$attrs
object, so
$listeners
has been removed.
If this component received an
id
attribute and a
v-on:close
listener, the
$attrs
object will now look like this: