angular - 错误:您应该使用 $timeout 服务而不是默认的 window.setTimeout 方法
问题描述
我在我的项目中使用 Angular 12 版本。
我使用了 setTimeout 函数,如下所示:
setTimeout(() => this.document.location.reload(), 2000);
当我运行时npm run eslintandfix
,我收到这样的错误
error You should use the $timeout service instead of the default window.setTimeout method angular/timeout-service
我在 package.json 中更新了 eslint 脚本,如下所示:
"elint": "eslint . --ext .ts",
"elintandfix": "eslint . --ext .ts --fix",
这是我的 package.json EsLint 插件的状态:
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-angular": "^4.0.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^5.2.1",
我找不到任何解决方案。请帮帮我。
先感谢您。
解决方案
推荐阅读
- c++ - 为什么在使用 SDL2 时仍然出现“未定义的引用”链接器错误?
- batch-file - 获取以特定字符串开头的行并将它们添加到之前的行 - bat file..windows
- c++ - VS 2017 Community 出现链接器错误,但 Professional 没有
- mariadb - 优化每天查看特定时间窗口的查询
- tsql - 如何在 SQL Operations Studio 中访问服务器属性?
- zos - 如何使用 Java 确定在 z/OS 上哪个安全管理器处于活动状态?
- swift - 如何以编程方式将 UILabel 和 UIImageView 添加到 CollectionView?
- javascript - 如何使用 JS 保持浏览器的离开页面警告不显示?
- json - 不再支持对inventory_quantity 和inventory_quantity_adjustment 的写入请求。请使用库存水平 API
- swift - 让用户在IOS swift中将pdf保存在应用程序之外