vue组件内数据更新后无法重新渲染组件解决办法

/ 0评 / 0
<components :lsit="list"></components>

//组件接收
props:{
  list:{
   type: Array,
   default() {
    return []
   }
  }
}

如果组件数据list在组件内更新了数据,组件可以无法渲染更新后的数据,需要处理一下:

//组件内
<components>
  <view v-for="(item,index) in newlist" :key="index"></view>
</components>

computed: {
  newlist(){
    return this.list
  }
}

组件内操作newlist数据就可以了。

如有错误,欢迎留言纠正!

发表评论

您的电子邮箱地址不会被公开。