Question: Assuming there's some `<Form>` component. It can be called with a `@cancel` event listener attached to it and if it's the case, I want to show the cancel button that triggers this event. If there's no `@cancel` event, the cancel button should not be visible.

Is there a way to check if a component has event listener attached to it?

Currently I do:

```
<template>
  <form>
    <button v-if="cancelEventPassed" @click="$emit('cancel')">Cancel</button>
  </form>
</template>

```

And call it like this:

```
<Form :cancelEventPassed="true" @cancel="handle_cancel" />

```

either

```
<Form/>

```

Is it possible to achieve this without using any additional property like `cancelEventPassed`?

Answer: 
This example for Vue 3
======================

```
this.$attrs.onCancel

```

Explanation
-----------

Vue 3 has removed the `$listeners` object instead listener will be parted from the `$attrs` object with the `on..` prefix.

Reference
---------

<https://v3-migration.vuejs.org/breaking-changes/listeners-removed.html#overview>
You can check if listener exists like that:
`this._events['listener-name']`