Complete the code to add a JavaScript hook for the enter transition in Vue.
<template> <transition @before-enter="[1]"> <div v-if="show">Hello</div> </transition> </template>
The @before-enter event expects a method name like beforeEnterHook to run before the enter transition starts.
Complete the code to define the JavaScript hook method for the leave transition.
<script setup> import { ref } from 'vue' const show = ref(true) function [1](el, done) { el.style.opacity = 0 setTimeout(() => { done() }, 300) } </script>
The leave hook is called when the leave transition starts. It receives the element and a done callback.
Fix the error in the transition hook usage by completing the code.
<template> <transition @[1]="fadeOut"> <p v-if="visible">Goodbye</p> </transition> </template>
The correct event for the leave transition hook is @leave. Other options are invalid event names.
Fill both blanks to correctly use JavaScript hooks for enter and leave transitions.
<template> <transition @[1]="onEnter" @[2]="onLeave"> <div v-if="active">Content</div> </transition> </template>
The @enter and @leave events trigger the JavaScript hooks for entering and leaving transitions.
Fill all three blanks to create a transition with JavaScript hooks for before-enter, enter, and after-leave.
<template>
<transition
@[1]="beforeEnter"
@[2]="enter"
@[3]="afterLeave"
>
<span v-if="show">Hi!</span>
</transition>
</template>Vue transition events use kebab-case names like before-enter, enter, and after-leave for JavaScript hooks.