undefinedfix
Sign in

Is there any difference between the data of the two objects in the Vue image?

gisshizuku45 edited in Sat, 18 Jun 2022

The following is the original data in the state, which is obtained from the background, and then the data in the articlelist is replaced. The following two pictures are printed out in different ways after replacement. I want to ask what is the difference between the results in the two pictures ? The first picture is the result of normal rendering after replacement. The second picture is the result of abnormal rendering. After replacing the data, the view still has the data in the original state. Can you tell us about the difference between the data of the two pictures

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
}

The first kind this.state.articleList = Object.assign ({}, this.state.articleList , data)

The second kind Vue.set ( this.state 'article list', data) is also this effect after it is updated in other ways, and cannot render normally

2 Replies
blwqh
commented on Sat, 18 Jun 2022

The effect of the two is the same. Is there any specific code online test example that can't reproduce your problem

Robocop
commented on Sun, 19 Jun 2022

Vue.set ( this.state ,'articlelist ', data) to this. $set( this.state Try it.

lock This question has been locked and the reply function has been disabled.