vue里面本身带有两个回调函数:
一个是Vue.nextTick(callback),当数据发生变化,更新后执行回调。
另一个是Vue.$nextTick(callback),当dom发生变化,更新后执行的回调。栗子:...

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

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-09-18
  • 2021-10-28
  • 2021-12-20
相关资源
相似解决方案