Transtion in vue is an animation transition encapsulation component. A common scenario is that the DOM wrapped with the transition tag contains animation effects. The animation effect transition settings of the transition component are based on the transition property settings of CSS. Here I will introduce the application of transition components in Vue in the project. Single pop-up applicationNotice:
<template> <div> <button v-on:click="show = !show"> Toggle </button> <transition name="fade"> <p v-if="show">hello</p> </transition> </div> </template> <script> export default { data () { return { show: true } }, } </script> <style scoped lang="less"> .fade-enter-active, .fade-leave-active { transition: all .5s; } .fade-leave-to { opacity: 0; transform: translateX(20px); } .fade-enter{ opacity: 0; transform: translateX(-20px); } </style> Content switching control effectNotice:
<template> <div> <transition name="fade"> <button class="position" @click="change" :key="status"> Component</button> </transition> </div> </template> <script> export default { data () { return { status: '1', } }, methods: { change () { if(this.docState === '1'){ this.docState = '2' }else{ this.docState = '1' } } } } </script> <style scoped lang="less"> .fade-enter-active, .fade-leave-active { transition: all .5s; } .fade-leave-to { opacity: 0; transform: translateX(20px); } .fade-enter{ opacity: 0; transform: translateX(-20px); } .position{ position: absolute; } </style> Use with animate frameworkNotice
<link href="https://cdn.jsdelivr.net/npm/[email protected]" rel="external nofollow" rel="stylesheet" type="text/css"> <div id="example-3"> <button @click="show = !show"> Toggle render </button> <transition name="custom-classes-transition" enter-active-class="animated tada" leave-active-class="animated bounceOutRight" > <p v-if="show">hello</p> </transition> </div> The page is loaded for the first time and the animation is executedAdding appear to transition This is the end of this article about the application of transition components in Vue projects. For more relevant content about transition components in Vue, please search previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: The pitfall record of case when judging NULL value in MySQL
Because I want to write a web page myself, I am al...
Preface Crond is a scheduled execution tool under...
Creating a Vue 3.x Project npm init @vitejs/app m...
The development history of CSS will not be introd...
Without further ado, let’s get straight to the co...
Table of contents Preface 1. Understanding with e...
Table of contents Preface Array.isArray construct...
<br />Related articles: 9 practical suggesti...
One environment Install VMware Tools on CentOS 7 ...
Part 1 Overview of SSH Port Forwarding When you a...
Some optimization rules for browser web pages Pag...
Preface Nodejs is a server-side language. During ...
Table of contents Overview Virtual Dom principle ...
Recorded the download and installation tutorial o...
Not only do different browsers behave differently...