zoukankan      html  css  js  c++  java
  • [转]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
  • 相关阅读:
    HDU6397
    容斥原理推导错排通项公式
    重复排列的证明
    圆排列证明
    rock-paper-scissors
    The more, The Better
    趁着情人节写点东西
    分层图最短路问题
    背包问题是否装满问题
    Python面向对象编程扑克牌发牌程序,另含大量Python代码!
  • 原文地址:https://www.cnblogs.com/freeliver54/p/9669103.html
Copyright © 2011-2022 走看看