我一直在尝试创建一个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>
随着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)
index.html目前看起来像……
<head> <title ng-bind="title">xxx</title> <Meta charset="utf-8" /> <Meta http-equiv="X-UA-Compatible" content="IE=edge,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>
修复Angular2 RC4 IE9:
原文链接:https://www.f2er.com/angularjs/240450.html>包含脚本:
< script src =“https://npmcdn.com/angular2@2.0.0beta.17/es6/dev/src/testing/shims_for_IE.js”>< / script>
>将路由方法更改为“#”
从’@ angular / common’导入{LocationStrategy,HashLocationStrategy};
…
bootstrap(AppComponent,[
…
{提供:LocationStrategy,useClass:HashLocationStrategy}
]);
>不要使用浏览器历史记录进行导航:
window.history.back(); //坏