美文网首页
VUE过渡&动画

VUE过渡&动画

作者: 陈老板_ | 来源:发表于2018-06-26 16:43 被阅读14次
  1. 操作 css 的 trasition 或 animation
  2. vue 会给目标元素添加/移除特定的 class
  3. 过渡的相关类名
    xxx-enter-active: 指定显示的 transition
    xxx-leave-active: 指定隐藏的 transition
    xxx-enter/xxx-leave-to: 指定隐藏时的样式
  1. 在目标元素外包裹<transition name="xxx">
  2. 定义 class 样式
    指定过渡样式: transition
    指定隐藏时的样式: opacity/其它
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /* 显示, 隐藏的过渡效果*/
        .xxx-enter-active,.xxx-leave-active{
            transition: opacity 1s;
        }
        /*隐藏时的样式*/
        .xxx-enter,.xxx-leave-to{
            opacity: 0;
        }
        /*显示的过渡效果*/
        .move-enter-active{
            transition: all 1s;
        }
        /*隐藏的过渡效果*/
        .move-leave-active{
            transition: all 3s;
        }
        /*隐藏时的样式*/
        .move-enter,.move-leave-to{
            opacity: 0;
            transform: translateX(20px);
        }
    </style>
</head>
<body>
    <div id="demo">
        <button @click="isShow=!isShow">toggle</button>
        <transition name="xxx">
            <p v-show="isShow">沈聪</p>
        </transition>
    </div>
    <div id="demo1">
        <button @click="isShow=!isShow">toggle</button>
        <transition name="move">
            <p v-show="isShow">沈聪</p>
        </transition>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    new Vue({
        el:'#demo',
        data:{
            isShow:true
        }
    })
    new Vue({
        el:'#demo1',
        data:{
            isShow:true
        }
    })
</script>
</html>

相关文章

  • VUE过渡&动画

    操作 css 的 trasition 或 animation vue 会给目标元素添加/移除特定的 class 过...

  • 2021-01-08

    Vue过渡和动画 Vue过渡和动画官方文档[https://cn.vuejs.org/v2/guide/trans...

  • 17.vue中多个元素或者多个组件的过渡动画列表过渡

    1.多个元素过渡动画 2.多个组件的过渡动画 3.vue中的列表过渡

  • Vue中多个元素或组件的过渡

    Vue中多个元素的过渡 Vue中多个组件的过渡(通过动态组件实现组件的过渡动画效果)image.png

  • Vue神一般的打开姿势

    过渡&动画 vue 动画的理解 1)操作 css 的 trasition 或 animation2)vue 会给目...

  • Vue动画

    Vue动画 Vue动画 CSS transition 在进入/离开的过渡中,会有 6 个 class 切换。 对于...

  • 【Vue3 从入门到实战 进阶式掌握完整知识体系】019-Vue

    四、Vue中的动画 1、使用 Vue 实现基础的 CSS 过渡与动画效果 过渡:比如说一个 div 的背景颜色从红...

  • vue过渡动画

    多标签名过渡时,如果标签名相同,必须在标签中加入key属性来对标签进行区分,否则动画不执行。 当然,您也可以使用不...

  • vue 过渡动画

    一、name值的定义,如图所示: 二、对四个阶段的深入理解 1.fade-enter和fade-leave的值一般...

  • Vue过渡动画

    vue可以在元素或组件进入和消失的时候提供过渡效果 使用过渡: vue会自动嗅探目标元素是否应用了 CSS 过渡或...

网友评论

      本文标题:VUE过渡&动画

      本文链接:https://www.haomeiwen.com/subject/yotmyftx.html