后端传来的数据是数据中包含几个对象:
[{"totalBlogs":6},{"commentsCount":1},{"totalClass":4}]
前端需要将上面的数据存放一个对象中,我的方法是:
1.遍历这个数组,用Object.keys取个每个key。
2.逐一给对象赋值。
data.forEach(item => {
const key = Object.keys(item)
console.log(key)
blogTotalData.value[key] = item[key]
})