Vue example code using transition component animation effect

Vue example code using transition component animation effect

Transition document address defines a background pop-up layer to achieve fade-in and fade-out effects

<template>
 <div>
  <button @click="show = !show">
   Toggle
  </button>
  <transition name="fadeBg">
   <div class="bg" v-if="show">hello</div>
  </transition>
 </div>
</template>

<script>
 export default {
  data: () => ({
   show: true
  }),
 };
</script>

<style lang="less" scoped>
 .fadeBg-enter-active,
 .fadeBg-leave-active {
  transition: opacity 0.3s ease;
 }

 .fadeBg-enter,
 .fadeBg-leave-to {
  opacity: 0;
 }

 .bg {
  position: fixed;
  top: 20px;
  left: 0;
  z-index: 105;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
 }
</style>

This is the end of this article about the example code of using transition component animation effect in Vue. For more relevant Vue transition component animation content, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to Vue transition failure in child components
  • Detailed explanation of the use of Vue components keep-alive and transition
  • How to implement transition encapsulation components in Vue
  • Use transition and transition-group in vue components to implement transition animation
  • Summary of the application of transition components in Vue projects

<<:  A brief discussion on docker-compose network settings

>>:  MySQL5.6.31 winx64.zip installation and configuration tutorial

Recommend

Detailed explanation of the use of stat function and stat command in Linux

stat function and stat command Explanation of [in...

Customization Method of Linux Peripheral File System

Preface Generally speaking, when we talk about Li...

A detailed introduction to for/of, for/in in JavaScript

Table of contents In JavaScript , there are sever...

How to handle spaces in CSS

1. Space rules Whitespace within HTML code is usu...

JavaScript Basics: Scope

Table of contents Scope Global Scope Function Sco...

Knowledge about MySQL Memory storage engine

Knowledge points about Memory storage engine The ...

Example explanation of MySQL foreign key constraints

MySQL's foreign key constraint is used to est...

Nodejs uses readline to prompt for content input example code

Table of contents Preface 1. bat executes js 2. T...

Vue realizes web online chat function

This article example shares the specific code of ...

How to build a complete samba server in Linux (centos version)

Preface smb is the name of a protocol that can be...

Detailed tutorial on using Docker to build Gitlab based on CentOS8 system

Table of contents 1. Install Docker 2. Install Gi...

Implementation of Vue 3.x project based on Vite2.x

Creating a Vue 3.x Project npm init @vitejs/app m...

Example code for CSS pseudo-classes to modify input selection style

Note: This table is quoted from the W3School tuto...