通俗易懂--快速入门Vue--4

时间:2020-01-23 21:45:36   收藏:0   阅读:71

1.Vue中Css动画原理

2.Vue中使用Animate.css库

3.Vue中同时使用过渡和动画

4.Vue中的Js动画与Velocity.js的结合

1.通过JS进行入场动画

2.JS进行出场动画

<transition
    name="fade"
    @before-leave="handleBeforeLeave"
    @leave="handleLeave"
    @after-leave="handleAfterLeave"
    > ......  </transition>

3.JS常用的动画库Velocity.js

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

1.多个元素的过渡

2.多个组件的过渡

6.Vue中列表过渡

7.Vue中的动画封装

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .v-enter,.v-leave-to{
            opacity:0;
        }
        .v-enter-active,.v-leave-active{
            transition: opacity 1s;
        }
    </style>
</head>
<script src="./vue.js"></script>
<body>
<div id="exp">
    <fade :show="show">
        <div>hello world</div>
    </fade>

    <fade :show="show">
        <h1>Hello world</h1>
    </fade>
    <button @click="handleClick">切换</button>
</div>
</body>
<script>

    // 创建一个组件封装动画效果,只要复用fade子组件就行了
    Vue.component("fade",{
        props:['show'],
        template:`
        <transition>
            <slot v-if="show"></slot>
        </transition>
        `
    });

    var vm = new Vue({
        // el限制一个vue实例的管理范围。
        el:"#exp",
        data:{
            show:true,
        },
        methods:{
            handleClick:function () {
                this.show = !this.show
            }
        }
    });
</script>
</html>
// 创建一个组件封装动画效果,只要复用fade子组件就行了
Vue.component("fade",{
    props:['show'],
    template:`
    <transition
    @before-enter="handleBeforeEnter"
    @enter="handleEnter"
    >
        <slot v-if="show"></slot>
    </transition>
    `,
    methods:{
        handleBeforeEnter:function (els) {
            els.style.color = "red";
0            },
        handleEnter:function (els,done) {
            setTimeout(() =>{
                els.style.color = "green";
                done()
            },2000)
        }
    }
});

8.动态过渡状态过渡

原文:https://www.cnblogs.com/xujunkai/p/12231387.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!