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

相关推荐
我命由我1234531 分钟前
React - 验证 Diffing 算法、key 的作用
javascript·算法·react.js·前端框架·html·html5·js
爱上妖精的尾巴7 小时前
8-18 WPS JS宏 正则表达式-边界匹配
开发语言·javascript·正则表达式·wps·jsa
爱上妖精的尾巴7 小时前
8-20 WPS JS宏 正则表达式-懒惰匹配
服务器·前端·javascript
网络点点滴7 小时前
组件通信props方式
前端·javascript·vue.js
weixin_443478517 小时前
flutter组件学习之Flex / Expanded弹性布局组件
javascript·学习·flutter
SuperEugene7 小时前
Excel 上传解析 + 导出实战:Vue+xlsx 避坑指南|Vue生态精选
前端·javascript·vue.js·excel·xlsx·vxetable
Highcharts.js7 小时前
使用Highcharts创建流图(Stream Graph)指南|流动数据的可视化图表与数据艺术表达
javascript·信息可视化·数据可视化·highcharts·可视化图表·流图·stream graph
努力往上爬de蜗牛7 小时前
el-table列表修改某个输入框输入 卡顿问题修改
javascript·vue.js·elementui
深念Y7 小时前
一个Bug:Vue Router 4.3.0 导致浏览器窗口无法最小化
前端·vue.js·bug·窗口·最小化·bilibili·视频网站
湛海不过深蓝7 小时前
【procomponents】根据表单查询表格数据的两种写法
前端·javascript·react.js