您的位置:首页 > 产品设计 > UI/UE

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

2018-04-12 11:10 621 查看
vue中依赖数组视图初始化后,后续数组更改,但是视图不更新,根据官网解释:



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();
} },
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息