es6 巢狀陣列迴圈 ES6關於陣列迴圈的問題

2021-10-18 18:52:23 字數 604 閱讀 1188

res.data.list 的資料 [, , ] 是陣列裡套json的形式

我想把res.data.list 迴圈放到乙個陣列裡 (因為要請求很多次資料,把每次返回的資料放在乙個陣列裡處理)

但是輸出的陣列顯示的是這樣的

[__ob__: observer]

length:4

__ob__:observer

__proto__:array

typeof 是object 沒法用陣列的方法

that.divicot=;//要輸出的陣列

for(var i in this.othercat){

getdivinationcont(this.othercat[i].id).then(function(res){ //從後台取資料

if(res.code<10000){

console.log(res.data.list)// 返回的資料

for(var t in res.data.list){//迴圈返回的資料

that.divicot.push(res.data.list[t]); //放進宣告的陣列裡

for in 和for of 都試了

實在是不知道了。。

ES6系列 ES6簡介

2015年6月17日,ecmascript的第六個版本正式發布,該版本正式名稱為ecmascript 2015,但通常被稱為ecmascript 6或者es6。瀏覽器對es6的支援情況 es6主要應用於node.js,如果想用在瀏覽器中,就需要使用轉碼器 將es6 轉成es5 這意味著,可以用es6...

ES6 陣列新增

window.onload function 作用 把類陣列 獲取一組陣列元素,arguments.物件轉成陣列 具備length這個東西,就靠譜 let arr 1,2,4 let arr2 array.from arr let json let arr array.from json 作用 把一...

ES6 陣列操作

1 push 尾端插入,返回陣列長度let arr 1,hello true console.log arr.push 22 4 console.log arr,arr 1,hello true,22 console.log arr.push false,123 6 console.log arr,...