有人能告訴我我的回調函數出錯了嗎? 我需要傳遞一個參數給函數來檢查它是否完成檢查,並返回true或false。用兩個參數回叫ES6箭頭函數Angular2
CheckPlayer(cb,player){
if(player >0){
console.log("true");
cb(true);
}
else{
console.log("False");
cb(false);
}
}
//This comes up with many errors
//The main typescript error says: ',' expected
CheckMe(){
player=10;
isGreat:Boolean;
this.CheckPlayer((isGreat,player) => {
if(isGreat)
console.log("Truth");
else
console.log("Fase");
});
}
你是不是傳遞的第一個參數this.checkPlayer(); 您將回調作爲第一個參數傳遞,然後應該是回調的第二個參數未定義。 – carmouche
首先擺脫語法錯誤。 – Pointy
@carmouch好吧我切換了兩個,但仍然是相同的錯誤 –