Angular 5在IE9上不起作用

时间:2018-04-12 19:29:32

标签: angular internet-explorer-9

enter image description here我有Angular Apps在IE11上运行正常, 但是当我在IE9上运行它时出现以下错误

  

可观察到的错误:错误:访问被拒绝。

     

SCRIPT438:对象不支持属性或方法'apply'   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';

我做错了什么? 我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

IE <10不具有CORS(跨源资源共享)支持。如果您有使用CORS发送AJAX调用的代码,则将无法支持IE <11。

据说IE 10支持CORS,但是在我看来,它仍然引发错误。我试图实现一些xdomain解决方案,但我也无法使它正常工作。 IE实在是太越野车了。

我建议不支持IE,因为MS似乎还是放弃了它。由于我没有看到任何优雅的方法可以在任何地方发布,因此我继续将解决方法放在这里:

您可以使用apache检测Internet Explorer <10,因此我创建了一个特殊的登录页面,将所有IE <10流量重定向到该页面。

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{HTTP_USER_AGENT} .*MSIE.*
    RewriteCond %{REQUEST_URI} !\.(css)$
    RewriteRule ^(.*) ie.html

</IfModule>

为了确保该文件包含在构建中,请确保将其添加到.angular-cli.json中的资产块中:

... 
"apps": [
{
  ...
  "assets": [
    ...
    "ie.html"
  ],