Documenting custom events
Coming now to the modal component, let's now add a button allowing it to be closed. To do this, we're going to add a button
element to the modal template with a click handler that emits an event close
.
src/components/Modal.vue
<template>
<div class="modal">
<slot></slot>
<button @click="$emit('close')">Dismiss</button>
</div>
</template>
Click to load comments...