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 });
} // 刚这里有个逗号