未捕获的TypeError:this._platformLocation.onPopState不是函数

时间:2019-03-25 11:25:18

标签: angular typescript

我构建了一个角度应用程序,如果我在非生产模式下运行它可以正常运行,但是如果我使用--prod运行它,则会出现以下错误:

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

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

  "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"
  }

有人可以解释为什么会发生此错误吗?为什么只在生产版本中弹出?

谢谢。

1 个答案:

答案 0 :(得分:0)

解决方案:问题在于,我使用的某些Web组件的ECMAScript版本比angular应用程序的版本还要旧。解决该问题可以解决此问题。