简体   繁体   English

Angular 5在IE9上不起作用

[英]Angular 5 Does not work on IE9

enter image description here I have Angular Apps that works fine on IE11, But when I run it on IE9 I got the following error 在此处输入图片描述,我有在IE11上都能正常工作的Angular Apps,但是当我在IE9上运行它时,出现以下错误

observable error: Error: Access is denied. 可观察到的错误:错误:访问被拒绝。

SCRIPT438: Object doesn't support property or method 'apply' localhost:4200, line 1 character 1 SCRIPT438:对象不支持属性或方法“应用” localhost:4200,第1行字符1

It fails in the following 它在以下失败

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);

Here is my pollyfills.ts 这是我的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';

What Did I do wrong ? 我做错了什么 ? Did I miss something ? 我错过了什么 ?

IE < 10 does not have CORS (Cross Origin Resource Sharing) support. IE <10没有CORS(跨源资源共享)支持。 If you have code that is sending an AJAX call using CORS, you will not be able to support IE < 11. 如果您有使用CORS发送AJAX调用的代码,则将无法支持IE <11。

Supposedly IE 10 has support for CORS, but it was still throwing errors in my case. 据说IE 10支持CORS,但是在我看来,它仍然引发错误。 I tried to implement some xdomain solutions but I couldn't get that to work either. 我试图实现一些xdomain解决方案,但我也无法使它正常工作。 IE was just too buggy. IE浏览器太过马车了

I would recommend not supporting IE since MS has seemed to abandon it anyway. 我建议不支持IE,因为MS似乎还是放弃了它。 Since I haven't seen any elegant ways of doing that posted anywhere, I'll go ahead and put my workaround here: 由于我没有看到任何优雅的方法可以在任何地方发布,因此我将继续介绍解决方法:

You can detect Internet Explorer < 10 using apache, so I created a special landing page that I redirect all IE < 10 traffic to. 您可以使用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>

In order to make sure that file is included in the build, make sure to add it to your assets block in .angular-cli.json: 为了确保该文件包含在构建中,请确保将其添加到.angular-cli.json中的资产块中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM