VueCLI核心知识4:动画效果、过渡效果

1 动画效果

【代码】

html 复制代码
<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>

    <!-- <transition name="xxx" :appear="true">   可以指定name属性,也可以不指定,name属性在有多个动画的时候比较有用 -->
    <transition :appear="true">
        <h1 v-show="isShow" class="hello">你好啊!</h1>
    </transition>
    
  </div>
</template>

<script>
    export default {
        name: 'Test',
        data() {
            return {
                isShow: true
            }
        }

    }
</script>

<style>
    .hello {
        background-color: skyblue;
        color: red;
        padding: 20px;
    }
    /* 动画 */
    .v-enter-active {
        animation: play .5s linear infinite;
    }
        
    .v-leave-active {
        animation: play .5s linear infinite;
        animation-direction: reverse;
    }

    @keyframes  play{
        from {
            transform: translateX(-100%);
        }
        to {
            transform: translateX(0px);
        }
    }
</style>

2 过渡效果


3 使用动画库实现动画效果

1.安装

css 复制代码
npm install animate.css

2.导入

复制代码
import 'animate.css';

3.使用

相关推荐
weixin_BYSJ19871 小时前
springboot3家政平台小程序--附源码00904
java·javascript·spring boot·python·django·flask·php
Wect2 小时前
TypeScript 完全指南
前端·javascript·typescript
清风programmer2 小时前
H5与小程序通信
前端·vue.js·uni-app
张元清2 小时前
React useDeepCompareEffect:修复 useEffect 的对象依赖问题(2026)
javascript·react.js
phltxy3 小时前
LangChain_v1_Agent快速开发和更新说明
前端·javascript·langchain
Cobyte3 小时前
通过 Vite 运行手写的模板编译器
前端·javascript·vue.js
用户298698530143 小时前
React 前端处理 Excel 工作表复制的技术实践
javascript·react.js·excel
光影少年3 小时前
RN原生交互 & 桥接
前端·javascript·react native·react.js·前端框架
张人玉3 小时前
基于 Vue 3 + ECharts + Express + SQLite 构—— LDA 模型的新闻舆论主题识别与情感分析系统
vue.js·echarts·express
用户526835677903 小时前
云原生运维实践:构建 Prometheus + 自定义 Webhook 的硬件声光告警闭环
javascript