【问题标题】:Uncaught TypeError: this._platformLocation.onPopState is not a function未捕获的类型错误:this._platformLocation.onPopState 不是函数
【发布时间】:2019-03-25 22:03:58
【问题描述】:

我构建了一个 Angular 应用程序,如果我在非生产模式下运行它,它运行良好,但如果我使用 --prod 运行它,我会收到以下错误:

Uncaught TypeError: this._platformLocation.onPopState is not a function

LocationStrategy 提供正确,它是最新的 Angular 版本,应该已经修复了这个错误。

  "dependencies": {
    "@angular/animations": "~7.0.4",
    "@angular/common": "~7.0.4",
    "@angular/compiler": "~7.0.4",
    "@angular/core": "~7.0.4",
    "@angular/forms": "~7.0.4",
    "@angular/http": "~7.0.4",
    "@angular/platform-browser": "~7.0.4",
    "@angular/platform-browser-dynamic": "~7.0.4",
    "@angular/router": "~7.0.4",
    "@ngx-translate/core": "~11.0.1",
    "@ngx-translate/http-loader": "~4.0.0",
    "@webcomponents/webcomponentsjs": "2.2.7",
    "core-js": "~2.5.7",
    "is-docker": "^1.1.0",
    "ngx-toastr": "^9.1.2",
    "lit-html": "~1.0.0",
    "rxjs": "~6.3.3",
    "split.js": "~1.5.9",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.1",
    "@angular/cli": "~7.0.6",
    "@angular/compiler-cli": "~7.0.4",
    "@angular/language-service": "~7.0.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~10.12.9",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "~0.2.2",
    "karma-detect-browsers": "~2.3.3",
    "karma-firefox-launcher": "^1.1.0",
    "karma-ie-launcher": "^1.0.0",
    "npm-run-all": "^4.1.5",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.1",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }

有人能解释为什么会发生这个错误吗?为什么它只在生产版本中弹出?

提前致谢。

【问题讨论】:

    标签: angular typescript


    【解决方案1】:

    解决方案:问题是我使用的一些 web 组件的 ECMAScript 版本比 Angular 应用程序旧。解决该问题解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-19
      • 1970-01-01
      • 2019-06-06
      • 2019-05-24
      • 2021-12-15
      • 2019-10-26
      • 2016-06-27
      相关资源
      最近更新 更多