javascript - js concat 方法 在RN中使用的疑问
本文介绍了javascript - js concat 方法 在RN中使用的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
console.log('这是的订单',this.state.page);
if(this.state.page>1) {
data=this.state.dataSource;
console.log('源数据',data);
data.concat(responseData.data);
for(i in responseData.data){
data.push(responseData.data[i]);
}
console.log('最后数据',data);
源数据
[
{
"article_id": "24",
"title": "不锈钢生锈的几大因素?",
"platform": "pc",
"type": "1",
"node_id": "23",
"author": "",
"pubtime": "1459987200",
"uptime": "1460443639",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "bd0f9369367d341d6ac9894bc6ac488a",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "25",
"title": "不锈钢为什么也会带磁?",
"platform": "pc",
"type": "1",
"node_id": "23",
"author": "",
"pubtime": "1460340000",
"uptime": "1460443631",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "b09a8ed49aeea2c7ddd9daf407adf6d5",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "21",
"title": "工业物联网发展必须克服的五大挑战导读",
"platform": "pc",
"type": "1",
"node_id": "22",
"author": "",
"pubtime": "1459900800",
"uptime": "1460443610",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "1c8a9da6c28f8e9b7cb5957a8cc29e1b",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "18",
"title": "拼钢网:钢铁融入互联网 小平台聚合大订单",
"platform": "pc",
"type": "1",
"node_id": "22",
"author": "",
"pubtime": "1460243880",
"uptime": "1460443544",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "09730766650fa37ab73bab9d89f96b35",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "27",
"title": "五类材质不同的不锈钢,知道有啥区别吗?",
"platform": "pc",
"type": "1",
"node_id": "23",
"author": "",
"pubtime": "1460332800",
"uptime": "1460443378",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "f9e64ffff2136fec06b31b621cd86854",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "26",
"title": "不锈钢管承受压力计算公式",
"platform": "pc",
"type": "1",
"node_id": "23",
"author": "",
"pubtime": "1460332800",
"uptime": "1460443287",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "1290da515f3b5b3ba2d874b71683a08b",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "23",
"title": "直径De、DN、D、d、Φ含义、区别",
"platform": "pc",
"type": "1",
"node_id": "23",
"author": "",
"pubtime": "1460332800",
"uptime": "1460443082",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "e7c3038f02916e4d56881055848d720c",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "22",
"title": "4月201走势预测!",
"platform": "pc",
"type": "1",
"node_id": "22",
"author": "",
"pubtime": "1460419200",
"uptime": "1460443029",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "5e737191673b2cdf5a9b92bd9c9866c2",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "20",
"title": "钢市现小狂潮!是需求真回暖?",
"platform": "pc",
"type": "1",
"node_id": "22",
"author": "",
"pubtime": "1460073600",
"uptime": "1460442838",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "2a904c350a5b6e60a39d734a08cae763",
"seoTitle": null,
"keywords": null,
"description": null
},
{
"article_id": "19",
"title": "镍观察:伦镍持续震荡走势",
"platform": "pc",
"type": "1",
"node_id": "22",
"author": "",
"pubtime": "1460332800",
"uptime": "1460442738",
"level": "1",
"ifpub": "true",
"pv": "0",
"disabled": "false",
"content": "2cd0c314ec830c7da5271e0d1d9b0bce",
"seoTitle": null,
"keywords": null,
"description": null
}
]
dataSource和responseData.data是完全相同的,问题为什么A处使用concat方法,却没有合并连个数组为新数组 B处使用for循环达到原始目的
解决方案
你需要 data = data.concat(somenewdate)
只有push, pop, shift, unshift, splice 这几个方法会作用在原数组上。
test
这篇关于javascript - js concat 方法 在RN中使用的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文