json对象剔除引发的悲剧。
json对象删除引发的悲剧。。。。。
看代码吧!
AllShuttleCity赋值给JsonData_CityAreaStore
然后根据条件删除JsonData_CityAreaStore里的对象
AllShuttleCity里面的也被删除了(应该是被删除了,数据太多没一一去看,因为长度减少了。)
每删一次JsonData_CityAreaStore.cityList 和 AllShuttleCity.ShuttleCityList的长度就减少1
想不通啊为什么AllShuttleCity会被删。求解释和处理方案。
------解决思路----------------------
因为那两个是同一个对象
JsonData_CityAreaStore.cityList =JSON.parse(JSON.stringify(AllShuttleCity.ShuttleCityList))
看代码吧!
JsonData_CityAreaStore.cityList = AllShuttleCity.ShuttleCityList;
for (var i = 0; i < JsonData_CityAreaStore.cityList.length; i++) {
if (!JsonData_CityAreaStore.cityList[i].IsSupportToHK) {
JsonData_CityAreaStore.cityList.splice(i, 1);
}
}
AllShuttleCity赋值给JsonData_CityAreaStore
然后根据条件删除JsonData_CityAreaStore里的对象
AllShuttleCity里面的也被删除了(应该是被删除了,数据太多没一一去看,因为长度减少了。)
每删一次JsonData_CityAreaStore.cityList 和 AllShuttleCity.ShuttleCityList的长度就减少1
想不通啊为什么AllShuttleCity会被删。求解释和处理方案。
------解决思路----------------------
因为那两个是同一个对象
JsonData_CityAreaStore.cityList =JSON.parse(JSON.stringify(AllShuttleCity.ShuttleCityList))