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

相关推荐
小飞侠在吗3 小时前
vue props
前端·javascript·vue.js
大怪v5 小时前
【Virtual World 03】上帝之手
前端·javascript
用户841794814565 小时前
vxe-gantt 甘特图实现产品进度列表,自定义任务条样式和提示信息
vue.js
招来红月7 小时前
记录JS 实用API
javascript
霍夫曼7 小时前
UTC时间与本地时间转换问题
java·linux·服务器·前端·javascript
VX:Fegn08957 小时前
计算机毕业设计|基于Java人力资源管理系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·后端·课程设计
꒰ঌ小武໒꒱7 小时前
文件上传全维度知识体系:从基础原理到高级优化
javascript·node.js
老华带你飞7 小时前
健身房|基于springboot + vue健身房管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端
JIngJaneIL7 小时前
基于Java酒店预约系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot
用户47949283569159 小时前
JavaScript 今天30 岁了,但连自己的名字都不属于自己
javascript