angular - 面对不是函数错误,但它在 Angular 上
问题描述
我正在开发一个 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...
}
}
有人可以显示我在哪里做错了吗?谢谢
解决方案
您正在调用slidefunction()
之前定义的相同。
先写函数,再调用。
推荐阅读
- r - 降价:!包 pdftex.def 错误;网上图片没找到?
- python - TensorFlow embedding_lookup_sparse 优化
- ruby - 如何在缓慢的任务之前启用打字指示器,发送带有结果的回复以及在使用 Stealth 停止打字指示器之前?
- entity-framework - EF Core 2.1 查询类型
- c++ - BLE gattServer.write() 重载函数
- database - 提交级别的数据库触发器或约束
- r - 从数据框中提取具有数值的列
- android - 存储高分辨率图像可绘制的最佳方法
- python - 无法导入预处理 python
- html - 带有 django 2.0.6 的 HTML 元素的列表(数组)