這里我有一個通用的計算功能。
private calculateTotal(order: InventoryOrder):number{
let total = 0.0;
if(order && order.currentInventory){
order.currentInventory.forEach(x =>{
console.log(x.quantity);
console.log("helloworld");
} //error appears here<- "," expected.
} return total;
}
我在https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach測驗了非常相似的代碼
const array1 = ['a', 'b', 'c'];
array1.forEach(element => {
console.log(element);
console.log("helloworld");
});
// expected output: "a"
// expected output: "b"
// expected output: "c"
知道發生了什么嗎?
uj5u.com熱心網友回復:
private calculateTotal(order: InventoryOrder):number{
let total = 0.0;
if(order && order.currentInventory){
order.currentInventory.forEach(x =>{
console.log(x.quantity);
console.log("helloworld");
});
}
return total;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/465053.html
標籤:javascript 数组 angularjs 前锋
