vue中依赖数组视图初始化后,后续数组更改,但是视图不更新,根据官网解释:

vue v-for初始化后, 数组更新但视图没更新的处理


1)源代码如下:

<div class="tab" ref="tab">
<div class="tab_content" ref="tabcontent" >
<game_block class="tab_item" v-for="(item, index) in lastPlayGameInfo" ref="tabitem" :gameinfo = 'item'></game_block >
</div>
</div>



2)监测数据变化,如果变化则set下,因为我是根据数组长度定义横向scroll的宽度,所以后来还refresh scroll宽度,具体的横向scroll的见我上一篇博客: https://blog.csdn.net/fanrenmuchangqian/article/details/79658743

watch: {
lastPlayGameInfo(lastPlayGameInfo){
console.log(1234);
this.lastGameInfo = [];
this.lastPlayGameInfo.forEach((value,index) => {
this.$set(this.lastGameInfo,index,value);
});
this.InitTabScroll();

}
},

相关文章: