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

相关推荐
万少1 天前
Vibe Coding不停歇,移动端 TRAE SOLO 让你用手机也能编程啦
前端·javascript·后端
kyriewen111 天前
WebAssembly:前端界的“外挂”,让C++代码在浏览器里跑起来
开发语言·前端·javascript·c++·单元测试·ecmascript
烛衔溟1 天前
TypeScript 接口的基本使用 —— 定义对象形状
前端·javascript·typescript
IT乐手1 天前
Claude Code + Qwen 的配置方法
javascript·claude
子兮曰1 天前
DeepSeek TUI:原生 Rust 打造的终端 AI 编码 Agent
前端·javascript·后端
暗不需求1 天前
# 深入 React Todos:从零实现一个状态提升与本地持久化的待办应用
javascript·react.js·全栈
子兮曰1 天前
深入 Superpowers:180k Stars 的开源 AI 编程方法论是如何工作的
前端·javascript·后端
不会敲代码11 天前
从零到一:用 Vue3 + Kimi 大模型打造「拍照记单词」AI 应用
vue.js·typescript·aigc
隔壁的大叔1 天前
Markdown 渲染如何穿插自定义组件
前端·javascript·vue.js
薯老板1 天前
JavaScript原型,原型链
javascript