我想将对象数组中的前 6 个元素推送到我新制作的数组中。我在网络浏览器上把它弄出来,但是或者“qwe”“qweqweqwe”我得到了 NaN。为什么?
假设来自 api 的对象数组如下所示:
0: {id: 340, name: "qwe", lastname: "qweqweqweq", …}
1: {id: 341, name: "qwe", lastname: "qweqweqweq", …}
2: {id: 342, name: "qwe", lastname: "qweqweqweq", …}
3: {id: 343, name: "qwe", lastname: "qweqweqweq", …}
4: {id: 344, name: "qwe", lastname: "qweqweqweq", …}
5: {id: 345, name: "qwe", lastname: "qweqweqweq", …}
6: {id: 346, name: "qwe", lastname: "qweqweqweq", …}
7: {id: 347, name: "qwe", lastname: "qweqweqweq", …}
8: {id: 348, name: "qwe", lastname: "qweqweqweq", …}
我的代码如下所示:
.then(response => {
console.log(typeof response.data, response.data);
this.model = {
name: response.data.name,
lastname: response.data.lastname
}
this.userInfo.unshift(this.model.name + this.model.lastname); // Here's where i have problem
if(this.userInfo.length > 6)
this.userInfo.pop();
})
.catch(error => {
console.log('Something went wrong', error);
});
},
30秒到达战场
RISEBY
杨__羊羊
相关分类