Home > Web Front-end > JS Tutorial > How to implement enter/leave animation in Vue

How to implement enter/leave animation in Vue

亚连
Release: 2018-06-15 14:37:44
Original
2547 people have browsed it

This article mainly introduces the Vue entry/leave animation effect. The code is simple and easy to understand, very good, and has reference value. Friends in need can refer to it

1. Example Code

(Note: written into vue single file)

<template>
  <p>
    <button v-on:click="show = !show">
      Toggle
    </button>
    <transition name="fade">
      <p v-if="show">hello</p>
    </transition>
  </p>
</template>
<script>
  export default {
    data: function() {
      return {
        show: true
      }
    }
  }
</script>
<style>
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity .5s
  }
  
  .fade-enter,
  .fade-leave-to {
    opacity: 0
  }
</style>
Copy after login

2. Description

(1)Needs transition tag package.

(2) 6 class status

(3) Effect:

The above is I compiled it for everyone, I hope it will be helpful to everyone in the future.

Related articles:

About browser suspended animation during ajax synchronization operation (detailed tutorial)

How to implement monitoring text boxes in js Enter the number of words (detailed tutorial)

What are the efficient algorithms in JavaScript

The above is the detailed content of How to implement enter/leave animation in Vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template