What is the trigger condition of appear-cancelled in Vue animation?

as the title: what is the trigger condition of appear-cancelled in Vue animation? What are the application scenarios? Thank you for the answer ~

Apr.21,2021

the following example is the perfect answer to your question

<template>
    <div>
        <transition
          appear
            v-on:before-appear="customBeforeAppearHook"
            v-on:appear="customAppearHook"
            v-on:after-appear="customAfterAppearHook"
            v-on:appear-cancelled="customAppearCancelledHook">
            <div ref="div" v-if="show">hello world</div>
        </transition>
    </div>
</template>

<script>
export default {
    data(){
        return {
            show: true
        }
    },
    methods: {
        customBeforeAppearHook(val){
            this.show = false

            console.log('customBeforeAppearHook')
        },
        customAppearHook(val){
            // this.show = false

            console.log('customAppearHook')
        },
        customAfterAppearHook(val){

            console.log('customAfterAppearHook')
        },
        customAppearCancelledHook(){
            console.log('customAppearCancelledHook')
        }
    },
    mounted(){
        console.log('mounted')
    }
}
</script>
< hr >

to sum up, the trigger condition is customBeforeAppearHook / customAppearHook two hook functions that do not display the operation v-if / v-show will trigger the appear-cancelled hook function. There are not many actual scenes, and some operations can be performed after the animation is cancelled by the user during the execution of the animation.

Menu