在IE9中使用Angular 2需要什么?

and*_*cwk 6 internet-explorer-9 angular

我一直在尝试创建一个Angular 2应用程序(使用入门指南)作为模板,但虽然它在Chrome中运行得非常好,但我很难让它在IE9中运行!

基本上,应用程序在加载/运行boot/js时失败,并向开发人员控制台报告以下错误.

日志:错误:对象不支持此操作

有没有人有任何建议或建议 - 甚至更好 - 一个实际在IE9中工作的演示?

我的index.html的开头如下所示......

<head>
<title ng-bind="title">xxx</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<base href="/">

<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<link rel="stylesheet" href="/css/style.css" />
<link rel="stylesheet" href="/css/main.css" />

</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.4.1/es5-sham.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.1/es6-sham.min.js"></script>
<script src="/app/shims_for_IE.js"></script>
<script src="https://rawgithub.com/systemjs/systemjs/0.19.6/dist/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js"></script>

<script>
    System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('app/boot')
        .then(null, function(err){
            console.log(err);
        });
</script>
Run Code Online (Sandbox Code Playgroud)

随着Angular代码跟随https://angular.io/guide/quickstart到信!

更新1:通过更多测试(主要是在较新的IE浏览器中)我正在尝试同样的问题,但看到更多细节..

    TypeError: Object doesn't support property or method 'keys'
   at Anonymous function (http://localhost:5000/app/angular2.dev.js:783:5)
   at Anonymous function (http://localhost:5000/app/angular2.dev.js:781:3)
   at linkDynamicModule (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js:3130:5)
   at getModule (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js:3098:9)
   at Anonymous function (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js:3134:9)
   at Anonymous function (http://localhost:5000/app/angular2.dev.js:10795:3)
   at linkDynamicModule (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js:3130:5)
   at getModule (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js:3098:9)
   at Anonymous function (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js:3134:9)
   at Anonymous function (http://localhost:5000/app/angular2.dev.js:12011:3)
Run Code Online (Sandbox Code Playgroud)

index.html目前看起来像......

<head>
<title ng-bind="title">xxx</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<base href="/">

<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<link rel="stylesheet" href="/css/style.css" />
<link rel="stylesheet" href="/css/main.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.4.1/es5-sham.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.1/es6-sham.min.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js"></script>

<script src="https://code.angularjs.org/tools/typescript.js"></script>

<script src="/app/reflect.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.src.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system-polyfills.src.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/Rx.js"></script>
<!--<script src="https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js"></script>-->
<script src="/app/angular2.dev.js"></script>



<script src="/app/shims_for_IE.js"></script>


<script>
    System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('app/boot')
        .then(function(){
        }, function(err){
            console.log(err.stack);
        });
</script>
Run Code Online (Sandbox Code Playgroud)

小智 5

修复Angular2 RC4 IE9:

  • 包含脚本:

<script src="https://npmcdn.com/angular2@2.0.0beta.17/es6/dev/src/testing/shims_for_IE.js"></script>

  • 将路由方法更改为"#"

import { LocationStrategy, HashLocationStrategy } from '@angular/common'; ... bootstrap(AppComponent, [ ..., { provide: LocationStrategy, useClass: HashLocationStrategy } ]);

  • 请勿使用浏览器历史记录进行导航:

window.history.back(); //BAD


and*_*cwk 2

所以,经过几个小时的拉扯之后,在这里与@kevinB(谢谢)进行了对话,并最终提出了一张罚单https://github.com/angular/angular/issues/6479#issuecomment-171582759

事实证明这是人为错误!

我从 cloudflare CDN 站点复制/粘贴了错误的链接,引用了 es6-sh a m.js 而不是 es6-sh i m.js

如此小的错字,却造成了严重的后果!