"对象不支持此操作"导航到IE中的新组件时出错

时间:2017-04-07 09:49:56

标签: angularjs angular internet-explorer typescript2.0

当我停留在某个组件并导航到另一个组件时,我收到了错误消息。如果我留在该组件并刷新,则不会显示错误。它发生在一些组件中。我尝试在内容中创建没有任何内容的新组件,如果我导航到此组件,它仍然会发生。错误消息以不间断的方式显示。

我正在使用Angular 2 final。它只是发生在IE中(使用IE11)。这是我的package.json:

"dependencies": {
    "@angular/common": "~2.2.0",
    "@angular/compiler": "~2.2.0",
    "@angular/core": "~2.2.0",
    "@angular/forms": "~2.2.0",
    "@angular/http": "~2.2.0",
    "@angular/platform-browser": "~2.2.0",
    "@angular/platform-browser-dynamic": "~2.2.0",
    "@angular/router": "~3.2.0",
    "@angular/upgrade": "^2.2.0",
    "@ng-idle/core": "^2.0.0-beta.4",
    "@ng-idle/keepalive": "^2.0.0-beta.4",
    "angular2": "^2.0.0-beta.17",
    "angular2-in-memory-web-api": "0.0.21",
    "angular2-jwt": "0.1.25",
    "bootstrap-sass": "^3.3.7",
    "core-js": "2.4.1",
    "font-awesome": "^4.7.0",
    "ng2-pagination": "^1.0.1",
    "ng2-translate": "4.0.0",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.12",
    "strip-bom": "^3.0.0",
    "typescript": "^2.1.4",
    "zone.js": "0.6.25"
  },
  "devDependencies": {
    "angular2-template-loader": "^0.6.0",
    "codelyzer": "1.0.0-beta.3",
    "copy-webpack-plugin": "^4.0.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.9.0",
    "gulp": "^3.9.1",
    "gulp-insert-lines": "0.0.4",
    "gulp-replace": "^0.5.4",
    "gulp-sass": "^2.3.2",
    "html-loader": "^0.4.4",
    "html-webpack-plugin": "^2.24.1",
    "istanbul-instrumenter-loader": "^1.0.0",
    "jasmine": "^2.5.2",
    "karma": "^1.3.0",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^1.0.2",
    "karma-mocha-reporter": "^2.2.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^1.8.0",
    "phantomjs-prebuilt": "^2.1.13",
    "raw-loader": "^0.5.1",
    "remap-istanbul": "^0.7.0",
    "ts-helpers": "^1.1.2",
    "ts-loader": "^1.2.1",
    "tslint": "^3.15.1",
    "tslint-loader": "^2.1.5",
    "typescript": "^2.1.4",
    "typings": "^2.0.0",
    "webpack": "^1.13.3",
    "webpack-dev-server": "^1.16.2"
  }

这是我的polyfill.ts:

import 'core-js';
import 'reflect-metadata';
import 'zone.js/dist/zone';

import 'ts-helpers';

if (process.env.ENV === 'prod') { // Production
    // @Todo: will be defined
} else {
    // Development
    Error['stackTraceLimit'] = Infinity;
    require('zone.js/dist/long-stack-trace-zone');
}

查看错误:

enter image description here

之前没有发生过。所以我无法找出根本原因和解决方案。有任何想法吗?感谢

1 个答案:

答案 0 :(得分:0)

最后我找到了根本原因。即使在没有所需对象的页面中,也可以从其他库以不间断的方式调用函数。没有提供任何对象,它导致了问题。我通过添加条件来修复它,以便在没有提供对象的页面中停止调用该函数。