2017-04-11 77 views
1

我正在写一个小应用程序来定位一些较旧的浏览器,但我很乐意将它写入Angular 4.可能吗?我需要哪些polyfils?AngularJS 4可以在IE9上运行吗?

+0

这取决于你想要做什么..? – Patrick

+0

check angular.io>文档>高级>浏览器支持 – Dummy

+0

https://angular.io/docs/ts/latest/guide/browser-support.html并向下滚动到“必填polyfills”。 – ceejayoz

回答

4

是的,它会工作在IE9

我建议使用Angular-CLI
假设你已经有了节点和NPM安装,使用角CLI运行:

npm install -g @angular/cli 
ng new PROJECT_NAME 

这应该是你所需要的,但如果您需要在此运行进一步帮助ng help

这得到你是基于Webpack的通用的Angular 4.0安装程序。为了支持IE9,你需要做另外两件事。

  1. 编辑src/polyfills.ts。取消IE9评论下的所有进口注释。这部分应该是这样算账:

    /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 
    import 'core-js/es6/symbol'; 
    import 'core-js/es6/object'; 
    import 'core-js/es7/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'; 
    import 'core-js/es6/regexp'; 
    import 'core-js/es6/map'; 
    import 'core-js/es6/set'; 
    import 'core-js/es7/array'; 
    
  2. 在tsconfig,编辑“目标”字段设置为"es5"。你的文件应该是这个样子以后

{ 
 
    "compileOnSave": false, 
 
    "compilerOptions": { 
 
    "outDir": "./dist/out-tsc", 
 
    "baseUrl": "src", 
 
    "sourceMap": true, 
 
    "declaration": false, 
 
    "moduleResolution": "node", 
 
    "emitDecoratorMetadata": true, 
 
    "experimentalDecorators": true, 
 
    "pretty": true, 
 
    "target": "es5", 
 
    "typeRoots": [ 
 
     "node_modules/@types" 
 
    ], 
 
    "lib": [ 
 
     "es2017", 
 
     "dom" 
 
    ] 
 
    } 
 
}

+1

它适合我...谢谢 –