If a <Form>
component is called with a @cancel
event listener attached to it, the cancel button that triggers this event should be visible. If no @cancel
event is present, the cancel button should not be displayed.
Is there a method to verify if a component has an event listener attached to it?
Currently, I use:
<template>
<form>
<button v-if="cancelEventPassed" @click="$emit('cancel')">Cancel</button>
</form>
</template>
To call it:
<Form :cancelEventPassed="true" @cancel="handle_cancel" />
or
<Form/>
Is it feasible to accomplish this without utilizing an additional property like cancelEventPassed
?