如何在vue js上同时添加两个过渡?

时间:2018-08-17 20:59:23

标签: javascript vue.js

我是Vue js框架的新手。我正在尝试在一个有效的元素中使用2过渡,但第二过渡效果不佳。 我的意思是第一个可以使用动画属性,但是第二个可以使用,但是动画不可以。

这是我的代码:

<div id="app-17" class="col-sm-4">
    <h1>Lista con VueJS - AJAX</h1>
    <button class="btn btn-sm btn-primary mb-4" v-on:click="show = !show">Mostar/Ocultar Lista</button>
    <button class="btn btn-sm btn-primary mb-4" v-on:click="shuffle">Shuffle</button>
    <transition-group name="flip-list" tag="ul">
                <li  v-if="show" v-for="item in list" v-bind:key="item.name">
                        {{item.name}}
                </li>
    </transition-group>

</div>

这是JavaScript:

<script type="text/javascript">
    var urlUsers = 'https://jsonplaceholder.typicode.com/users'
        app17 = new Vue({
            el: '#app-17',
            created: function(){
                this.getUsers();
            },
            data: {
                list: [],
                show: false
            },
            methods: {
                getUsers: function () {
                    this.$http.get(urlUsers).then(function (response) {
                        this.list = response.data;
                    });
                },
                shuffle: function () {
                    this.list = _.shuffle(this.list)
                }
            }
        })
    </script>

和CSS样式:

<style>
        /*ANIMATION APP-8*/

        .fade-enter-active,
        .fade-leave-active {

            transition: opacity .5s;

        }

        .fade-enter,
        .fade-leave-to
        /* .fade-leave-active below version 2.1.8 */

            {
            opacity: 0;

        }

        .flip-list-move {
            transition: transform 1s;
        }
    </style>

我也在使用这些链接:

 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
        crossorigin="anonymous">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.14.1/lodash.min.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.5.1/vue-resource.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
    crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
    crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
    crossorigin="anonymous"></script>

这里是真实的例子: https://codepen.io/blackandnoob/pen/qyeJVW

0 个答案:

没有答案