javascript - setTimeout 不适用于 Angular5

标签 javascript angular5

this.fetchRequests(this) 在 View 初始化后立即执行,而不是等待 20 秒。

我知道在旧版本中我们必须使用包装器,但我猜在新版本中不需要这些。对此的任何帮助都会有所帮助。

ngAfterViewInit() {
    setTimeout(()=>{
        this.fetchRequests(this);
    }), 10000;
}

最佳答案

我认为你写错了语法 这段代码

setTimeout(()=>{
    this.fetchRequests(this);
}), 10000;

应该是这样的

setTimeout(()=>{ this.fetchRequests(this); },1000);

关于javascript - setTimeout 不适用于 Angular5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47953678/

相关文章:

javascript - 如果助手不在了,如何从 Grunt 中的代码调用任务

javascript - 从一对多关系获取和保存值,并在 Laravel 的 javascript 中使用

angular5 - Angular中Highcharts的TreeMap图表

javascript - 根据数组 Angular 中的位置删除和添加类

html - 'hgroup' 不是 Angular 5 中的已知元素错误

php - Angular 将 Array 作为对象并且不显示值

javascript - Angular 5 : setting (click) value from an object not working

javascript - 是否可以使用 javascript 扩展手写笔?

javascript - 从标签中提取属性的 jQuery 表达式

javascript - 动态添加 html 后使 javascript 工作