vue图片上这两个对象的数据有什么不同吗?

下面是state里面原来的数据 从后台获取到的数据然后替换掉articleList的数据
下面两张图片是不同方式替换后打印出来的结果 我想问一下两张图片上的结果有什么不一样的?
第一张图片是替换后可以正常渲染的结果 第二张是不能正常渲染 替换数据后视图还有原来的state里面的数据 大家能说说两张图片的数据哪里不一样吗

export default {
  routeName: '',
  auth: 1,
  list: ['a', 'b', 'c'],
  errors: [],
  articleList: [
    {
      userinfo: {image: 'static/img/3.jpeg', nickname: 'eee', text: '嘿嘿', time: '十天前'},
      content: {href: '2222222', text: 'test', create_time: '', updata_time: ''},
      pic: [{path: 'static/img/0.jpg'}, {path: 'static/img/0.jpg'}, {path: 'static/img/0.jpg'}],
      likebar: {hot: 555, status: false, comments: 666},
      isFollow: true
    },
    {
      userinfo: {image: 'static/img/3.jpeg', nickname: 'eee', text: '嘿嘿', time: '十天前'},
      content: {href: '', photo: '', text: 'test', create_time: '', updata_time: ''},
      pic: [{path: 'static/img/0.jpg'}, {path: 'static/img/1.jpg'}, {path: 'static/img/3.jpeg'}],
      likebar: {hot: 555, status: false, comments: 666},
      isFollow: false
    }
  ],
  dd: false
}

第一种
this.state.articleList = Object.assign({}, this.state.articleList, data)
图片描述

第二种
Vue.set(this.state, 'articleList', data)
用其它方式更新后也是这种效果 不能正常渲染
图片描述

阅读 1.6k
2 个回答

Vue.set(this.state, 'articleList', data)改成this.$set(this.state, 'articleList', data)试试。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题