【发布时间】:2021-11-21 21:57:40
【问题描述】:
我正在开发一个 html、css、js 滑块,但遇到了一个奇怪的错误。 我正在研究角度
这是错误
core.js:6479 ERROR TypeError: this.slideFunction is not a function
at autoSlide (home.component.ts:32)
at timer (zone.js:2561)
at ZoneDelegate.invokeTask (zone.js:406)
......................................
......................................
这就是我的代码的样子
export class HomeComponent implements OnInit {
counter:number = 1;
timer: any;
constructor() { }
ngOnInit(): void {
//change the current slide to the next one after 8 secondes by calling the autoSlide function
this.timer = setInterval(this.autoSlide,8000);
}
autoSlide() {
this.counter += 1;
this.slideFunction(this.counter);
}
//Function that handle the change
slideFunction(slideNumber: number): void{
My logic goes there...
}
}
有人可以显示我在哪里做错了吗? 谢谢
【问题讨论】:
标签: angular function setinterval