下面是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)
用其它方式更新后也是这种效果 不能正常渲染
两者效果是一样的 有没有具体代码
在线测试例子
无法复现你的问题