【发布时间】:2018-04-12 19:29:31
【问题描述】:
enter image description here我有在 IE11 上运行良好的 Angular 应用程序, 但是当我在 IE9 上运行它时,我得到了以下错误
可观察到的错误:错误:访问被拒绝。
SCRIPT438:对象不支持属性或方法“应用” localhost:4200,第 1 行字符 1
以下失败
const headers = new Headers({ 'Content-Type': 'text/xml',
'cache-control': 'no-cache',
'Access-Control-Allow-Methods':'POST, GET, OPTIONS',
'Access-Control-Allow-Origin':'*'});
let RetCaseNumner=''
const options = new RequestOptions({ headers: headers });
return this.http.post(this.url, this.jsonBody, options)
.map((res: Response) => {
let ret =JSON.parse(res.text())
let ResponseBody = ret.EventMessageResponse.Response.ResponseBody
xml2js.parseString(ResponseBody,function(err, result){
RetCaseNumner =result.Result.CaseNumber[0]
return RetCaseNumner;
});
return RetCaseNumner
})
.do(data => console.log('Inside do Case Number: ' + (data)))
.catch(this.handleError);
这是我的 pollyfills.ts
// This file includes polyfills needed by Angular and is loaded before the app.
// You can add your own extra polyfills to this file.
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
//This get rid of SCRIPT438: Object doesn't support property or method 'apply'
import 'core-js/es7/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/weak-set';
import 'core-js/es6/typed';
import 'core-js/es6/set';
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
(window as any).__Zone_enable_cross_context_check = true;
import 'zone.js/dist/zone';
import 'zone.js/dist/long-stack-trace-zone';
// If you need to support the browsers/features below, uncomment the import
// and run `npm install import-name-here';
// Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
// Needed for: IE9
// import 'classlist.js';
// Animations
// Needed for: All but Chrome and Firefox, Not supported in IE9
// import 'web-animations-js';
// Date, currency, decimal and percent pipes
// Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
// import 'intl';
// import 'intl/locale-data/jsonp/en';
// NgClass on SVG elements
// Needed for: IE10, IE11
import 'classlist.js';
/**
* rxjs
*/
import 'rxjs/bundles/Rx';
import 'rxjs/add/observable/interval';
import 'rxjs/add/observable/merge';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/takeUntil';
import 'rxjs/add/operator/throttleTime';
import 'rxjs/add/operator/timeInterval';
import 'rxjs/add/operator/toPromise';
//This get rid of SCRIPT438: Object doesn't support property or method 'apply'
// import '@angular/core/bundles/core.umd';
import '@angular/common/bundles/common.umd';
import '@angular/compiler/bundles/compiler.umd';
import '@angular/platform-browser/bundles/platform-browser.umd';
import '@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd'
import 'ie9-oninput-polyfill';
import 'angular-polyfills/dist/blob';
import 'angular-polyfills/dist/classlist';
import 'angular-polyfills/dist/formdata';
import 'angular-polyfills/dist/intl';
import 'angular-polyfills/dist/shim';
import 'angular-polyfills/dist/typedarray';
import 'console-polyfill';
我做错了什么? 我错过了什么吗?
【问题讨论】:
-
你在使用 Angular CLI 吗? IE 9+ 从来没有遇到过问题,只是将它作为标准使用并在 polyfills 文件中安装它所说的内容(包括 npm 安装)。尝试查看一个新项目的文件并从那里开始。
-
谢谢巴格利,我开始了一个全新的 Angular CLI 项目并取消注释 IE9 的 pollyfills,但相同的代码在 IE11 和 IE9 上运行良好,引发访问被拒绝和 SCRIPT438:对象不支持属性或方法“应用”
-
从快速概览看来,错误并非来自您所想的地方,而可能是代码中的其他地方。您发布的代码没有错误,只要不是在严格模式下运行,它应该可以在 ie 9+ 中正常工作。除非您将此作为客户要求,否则我建议您顺其自然。 ie 11 被认为是 ie 浏览器的最后一个非弃用版本。下面的任何内容都有安全隐患,不应该使用是一般的想法。
-
做微软做的事...停止支持旧浏览器
标签: angular internet-explorer-9