vue--about CSS transitions and animations

Source: Internet
Author: User
Tags custom name

1. Transition of single element/component

Vue provides transition a package component that can add entry/exit transitions to any element and component in the following scenarios

    • Conditional rendering (using v-if )
    • Condition display (use v-show )
    • Dynamic components
    • Component root Node

Instance:

<style>    . Fade-enter,. fade-leave-to { opacity:  0;     }    . fade-enter-active,. fade-leave-active { transition:  opacity. 5s;     }</style>
<!--fade is a custom name that will be prefixed with the class "Fade-enter"-  
< Div id= "app" > <transition name= "Fade" > <div v-if= "Show" >
<script>NewVue ({el:'#app', data:{Show:true}, methods:{HandleChange:function(){                 This. Show= ! This. Show; }        }    })</script>

2. The class name of the transition

In the transition to/from, there will be 6 class switches: V-enter, v-enter-active, V-enter-to, V-leave, V-leave-active, v-leave-to

About the Transition class name:

If you use a name that is not named <transition> , it v- is the default prefix for these class names.

If you use it <transition name="my-transition"> , it v-enter will be replaced bymy-transition-enter

3. About animations (omitted here)

4. Use of third-party animate.css libraries in Vue

first link introduces Animate.css, then combines the class name of the custom transition Enter-active-class, Leave-active-class,

  Animated is a must-write, hinge shake is an animated effect introduced

<div id= "App" >    <transition enter-active-class= "animated hinge" Leave-active-class= " Animated Shake">        <div v-if=" show ">show</div>    </transition>    <button @ click= "HandleChange" >change</button></div>
<Script>    NewVue ({el:'#app', data:{Show:true}, methods:{HandleChange:function(){                 This. Show= ! This. Show; }        }    })</Script>

vue--about CSS transitions and animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.