Angular找不到变量缓存

标签 angular go heroku safari

当我在本地运行我的 Angular 应用程序时,它在所有东西上都可以正常运行,但是如果我将它部署在 Heroku 上 - 在 Go 服务器中,则在 Chrome 和 Opera 上的 Angular 构建上禁用 aot - 在移动设备、Linux 和 osx 上 - 但它会引发错误在 Safari :

ReferenceError: Can't find variable: Cache

当我仔细查看错误时,我想它来自我的模块提供程序。因为它需要我:
 main-es2015[...].js

[...], IP, KM, {
            provide: Cache, // error
            useClass: KM,
            multi: !0
        }],

对应的app.module.ts部分
providers: [
    {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true},
    {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptorService, multi: true},
    {provide: HTTP_INTERCEPTORS, useClass: CachingInterceptor, multi: true},
    ApplicationStateService,
    CacheMapService,
    {provide: Cache, useClass: CacheMapService, multi: true}
  ],

缓存提供程序不是多的,而是多的,但没有区别

最佳答案

有一个变量名为:

declare var Cache: {prototype: Cache; new():Cache}

lib.dom.d.ts文件。我使用这个变量而不是我的 cache.ts模型。我太傻了...
如果您也有缓存模型,请将其放在 *.module.ts 文件的顶部
import {Cache} from 'path-to-cache-file'

关于Angular找不到变量缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58377155/

相关文章:

angular - 如何使用 Angularfire2 从 Firebase 存储中删除

angular - 为什么不是所有的 Angular 包都声明为 devDependency?

angular - Nativescript 后退按钮没有重定向到正确的页面

multithreading - 我的 Go 程序如何让所有 CPU 内核保持忙碌状态?

cookies - herokuapp.com 上的 Heroku 应用程序中的 Cookie 安全吗?

angular - 在 Angular 项目中使用 Jasmine 调用测试回调函数

go - 基于拆分字符串和键值对生成动态嵌套映射

go - 如何通过 Go 的 MaxBytesReader 确定我是否达到了大小限制

Heroku 日志记录不起作用

ruby-on-rails - 如果来自不同分支的后续迁移已经运行,如何在 Heroku 上运行来自 Git 分支的迁移?