Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

vue视图未及时更新

<div style="width:130px;height:40px;line-height:40px;">
  <button style="border:none;background:none;height:40px;vertical-align: middle;font-weight:600;float:left"><i class="iconaixin iconfont" style="vertical-align: middle;"></i>点赞</button>
  <button v-on:click="publishComment(dynamic._id,index)" style="border:none;background:none;height:40px;vertical-align: middle;float:right;font-weight:600;" ><i class="iconxiaoxi iconfont" style="vertical-align: middle;"></i>评论</button>
</div>

publishComment(_id,index){
      var  _this = this; 
      _this.$set(_this.dynamicLists[index],'publishComment',true) 
     console.log(this.dynamicLists[index].publishComment)
          console.log(this.dynamicLists)
    
      }                          

相通过点击事件修改数组里面的值,this.$set未能及时更新视图,只修改了数组里面的数据,向大佬请教?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

this.$forceUpdate();
强制刷新


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...