var warehouseData=[
{
"WarehouseId":1,
"ThirdParyId":301,
"WarehouseName":"香港",
"WarehouseType":"海外仓库",
"WarehouseDesc":"小仓库",
},
{
"WarehouseId":2,
"ThirdParyId":302,
"WarehouseName":"深圳",
"WarehouseType":"本地仓库",
"WarehouseDesc":"大仓库",
},
]
这是仓库的数据,现在要对其中的一条数据进行编辑修改,随便写了个函数,具体如下:
UpdateWarehouse(obj, callback) {
for(var i=0;i<warehouseData.length;i++){
if(warehouseData[i].WarehouseId==obj.WarehouseId){
warehouseData[i] = obj;
}
}
callback({ Success: true });
},
调用时,竟然不起作用,请问大神们 是不是这样子写是错误的?
三叔2017-06-12 09:33:57
是不是这函数前面少个了词 function
?
然后再把那逗号移除掉,, 试试
function UpdateWarehouse(obj, callback) {
for(var i=0;i<warehouseData.length;i++){
if(warehouseData[i].WarehouseId==obj.WarehouseId){
warehouseData[i] = obj;
}
}
callback({ Success: true });
} // 刚这里有个逗号