Sakiya

vue this.$nextTime如何使用

<ul id="demo">
        <li v-for="item in list">{{item}}</li>
</ul>
<script>
    var app = new Vue({
        el: '#demo',
        data: {
            list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
            msg: 'hello'
        },
        methods: {
            push: function () {
                this.list.push(11);
                this.$nextTick(function () {
                    alert('v-for渲染已经完成')
                                })
                        }
                }
        });

    app.push();
    console.log(app)
</script>

评论

© Sakiya | Powered by LOFTER