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.使用

相关推荐
瑞瑞小同学2 小时前
处理echarts x轴内容过多,重叠问题
前端·javascript·echarts
像我这样帅的人丶你还2 小时前
MCP + npm:给五年前的老系统接上AI
前端·javascript·agent
Larcher3 小时前
LangChain RAG 排错实录:.env 为什么没有生效
vue.js·后端
猫头_4 小时前
AI 流式传输工程指南:有了 EventSource 为何还要 Fetch?
javascript·http·llm
活于未来4 小时前
从零搭建期权波动率曲面可视化平台:FastAPI + Vue 3 实战
vue.js
橘子海全栈攻城狮5 小时前
【最新源码】基于SpringBoot + Vue的超市管理系统的设计与实现D002
java·开发语言·vue.js·spring boot·后端·spring
良木林5 小时前
滑动窗口 - LeetCode hot 100
javascript·算法·leetcode·双指针·滑动窗口
不简说7 小时前
# JS 代码技巧 vol.7 — 20 个浏览器 API 实战,自带 API 能干的事别自己封装
前端·javascript·面试
Hilaku7 小时前
为什么 Cloudflare 能做到毫秒级冷启动,而其它云厂商却不行?
前端·javascript·程序员
2301_794461577 小时前
JavaScript 基础知识点详解
前端·javascript·html