export class HomePage {
percent = 0;
radius = 100;
fullTime: any = '00:01:30';
timer: any = false;
progress: any = 0;
minutes: 1;
seconds: any = 30;
startTime() {
this.timer = false;
this.percent = 0;
this.progress = 0;
const timeSpilt: any = this.fullTime.spilt(':');
this.minutes = timeSpilt[1];
this.seconds = timeSpilt[2];
const totalSeconds: number = Math.floor(this.minutes * 60) + parseInt(this.seconds);
this.timer = setInterval(() => {
if (this.percent === this.radius) {
clearInterval(this.timer);
}
this.percent = Math.floor((this.progress / totalSeconds) * 100);
this.progress++;
}, 1000);
}
}
错误:
ERROR TypeError: this.fullTime.spilt is not a function
at HomePage.push../src/app/home/home.page.ts.HomePage.startTime (home.page.ts:24)
at Object.eval [as handleEvent] (HomePage.html:6)
at handleEvent (core.js:23097)
at callWithDebugContext (core.js:24167)
at Object.debugHandleEvent [as handleEvent] (core.js:23894)
at dispatchEvent (core.js:20546)
at core.js:20993
at HTMLElement.<anonymous> (platform-browser.js:993)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17280)
答案 0 :(得分:0)
您的函数方法中有错别字: 拆分确实不起作用,请尝试使用拆分
this.fullTime.split(':')