The video for this lesson is currently being updated, please read the transcript instead.

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>

To view the complete lesson you'll need to login or join this course.


Click to load comments...