• [转]Angular 2 / 4 / 5 not working in IE11


    本文转自:https://stackoverflow.com/questions/35140718/angular-2-4-5-not-working-in-ie11/47777695#47777695

    The latest version of angular is only setup for evergreen browsers by default...

    The current setup is for so-called "evergreen" browsers; the last versions of browsers that automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 
    This also includes firefox, although not mentioned.

    See here for more information on browser support along with a list of suggested polyfills for specific browsers. https://angular.io/guide/browser-support#polyfill-libs


    This means that you manually have to enable the correct polyfills to get Angular working in IE11 and below.


    To achieve this, go into polyfills.ts (in the src folder by default) and just uncomment the following imports:

    /***************************************************************************************************
     * BROWSER POLYFILLS
     */
    
    /** IE9, IE10 and IE11 requires all of the following polyfills. **/
     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';
     import 'core-js/es6/regexp';
     import 'core-js/es6/map';
     import 'core-js/es6/set';
    

    Note that the comment is literally in the file, so this is easy to find.

    If you are still having issues, you can downgrade the target property to es5 in tsconfig.json as @MikeDub suggested. What this does is change the compilation output of any es6 definitions to es5 definitions. For example, fat arrow functions (()=>{}) will be compiled to anonymous functions (function(){}). You can find a list of es6 supported browsers here.

    For me with iexplorer 11 and Angular 2 I fixed all those above issues by doing 2 things:

    in index.html add:

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    

    in srcpolyfills.ts uncomment:

    /** IE9, IE10 and IE11 requires all of the following polyfills. **/
    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';
    import 'core-js/es6/regexp';
    import 'core-js/es6/map';
    import 'core-js/es6/weak-map';
    import 'core-js/es6/set';




    https://angular.io/guide/quickstart
  • 相关阅读:
    结对编程项目---四则运算
    作业三(代码规范、代码复审、PSP)
    作业2(源程序管理软件与项目管理软件)
    学习总结
    作业1
    寒假超市实习
    《软件工程》课程总结
    结对编程项目---四则运算
    作业三: 代码规范、代码复审、PSP
    作业二(2)目前流行的源程序版本管理软件和项目管理软件都有哪些,各有什么优缺点?
  • 原文地址:https://www.cnblogs.com/freeliver54/p/9669103.html
Copyright © 2020-2023  润新知