猿问

如何按现有元素的相同顺序推送数组元素

我有一个productData包含 69 个元素的数组,并且productDatagreen在应用程序中有 659 个元素angular。当我这样做时,push所有 659 个元素都进入索引 69,同样的事情发生了cancat。然后我总共有length70 个数组。


我需要length数组 69+659 并且项目应该在同一行中。我怎样才能做到这一点。这是我的代码。


this.productData.push(this.productDatagreen)

this.productData= this.productData.concat([this.productDatagreen])    

this.mapImageSeries.data=this.productData;

this.Chart.validateData();

数组截图

holdtom
浏览 110回答 2
2回答

紫衣仙女

你可以这样做this.productData =[...this.productData,...this.productDatagreen]console.log(this.productData.length);//will console 728

红颜莎娜

this.productData.push(...this.productDatagreen)为我工作。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答