ERROR在SRC /应用/ logger.ts(18,16):错误TS1005: '(' 预期
这是我班记录,并在这里将在setTimeout的显示错误功能 -ERROR在SRC /应用/ logger.ts(18,16):错误TS1005: '(' 预期
export class logger{ WriteLogger() {
let dateTime,dd,mm,yyyy,h,m,s,m1,s1;
console.log("logger class is called");
//console.log(new Date().getCurrent);
dateTime = new Date();
dd = dateTime.getDate();
mm = dateTime.getMonth() + 1;
yyyy = dateTime.getFullYear();
h = dateTime.getHours();
m = dateTime.getMinutes();
s = dateTime.getSeconds();
m = this.checkTime(m);
s = this.checkTime(s);
setTimeout((=> {
console.log(dd + "/" + mm + "/" + yyyy + " The Current Time is " + h +":" + m + ":" +s);
}),500);
}
checkTime(i){
if(i<10){
i = "0" + i;
}
}
}
但我正在此错误:
ERROR in src/app/logger.ts(18,16): error TS1005: '(' expected
回答:
setTimeout
应该self invoking
变化setTimeout
setTimeout((=> { console.log(dd + "/" + mm + "/" + yyyy + " The Current Time is " + h +":" + m + ":" +s);
}),500);
要
setTimeout(() => { console.log(dd + "/" + mm + "/" + yyyy + " The Current Time is " + h +":" + m + ":" +s);
}, 500)()
以上是 ERROR在SRC /应用/ logger.ts(18,16):错误TS1005: '(' 预期 的全部内容, 来源链接: utcz.com/qa/260959.html