美文网首页
vue零基础开发024——Vue中同时使用过渡和动效

vue零基础开发024——Vue中同时使用过渡和动效

作者: 文朝明 | 来源:发表于2019-12-03 16:51 被阅读0次
<html>
<head>
    <meta charset="utf-8" />
    <title>Vue中同时使用过渡和动效</title>
    <script src="./vue.js"></script>
    <link rel="stylesheet" type="text/css" href="./animate.css">
    <style>
        .fade-enter, .fade-leave-to {
            opacity: 0
        }

        .fade-enter-active, .fade-leave-active {
            transition: opacity 5s;
        }
    </style>
</head>
<body>
    <div id="root">
        <!--type设定时长的参照标准type="transition"--:duration直接规定动画秒数:duration="5000"-->
        <transition name="fade"
                    :duration="{enter:5000,leave:10000}"
                    appear
                    enter-active-class="animated swing fade-enter-active"
                    leave-active-class="animated shake fade-leave-active"
                    appear-active-class="animated shake">
            <div v-if="show">hello world</div>
        </transition>
        <button @click="handleClick">切换</button>
    </div>
    <script>

        var vm = new Vue({
            el: "#root",
            data: {
                show: true
            },
            methods: {
                handleClick: function () {
                    this.show = !this.show
                }
            }
        })

    </script>
</body>
</html>

相关文章

网友评论

      本文标题:vue零基础开发024——Vue中同时使用过渡和动效

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