`

Angular 兼容IE方法

阅读更多



 

版本:本文Angualr 版本基于6.1.0

背景:在学习官方Hero教程到路由这一章时,想在IE打开 http://localhost:4200/dashboard ,后台报错,不兼容。

解决方法:在工程中找到 polyfills.ts 这个文件打开,内容如下(已修改完成):

/**
 * This file includes polyfills needed by Angular and is loaded before the app.
 * You can add your own extra polyfills to this file.
 *
 * This file is divided into 2 sections:
 *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
 *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
 *      file.
 *
 * 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.
 *
 * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
 */

/***************************************************************************************************
 * 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/weak-map';
import 'core-js/es6/set';

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js';  // Run `npm install --save classlist.js`.

/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';


/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect';


/**
 * Web Animations `@angular/platform-browser/animations`
 * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
 * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
 **/
//import 'web-animations-js';  // Run `npm install --save web-animations-js`.

/**
 * By default, zone.js will patch all possible macroTask and DomEvents
 * user can disable parts of macroTask/DomEvents patch by setting following flags
 */

// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
 // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
 // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames

 /*
 * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
 * with the following flag, it will bypass `zone.js` patch for IE/Edge
 */
// (window as any).__Zone_enable_cross_context_check = true;

/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import 'zone.js/dist/zone';  // Included with Angular CLI.



/***************************************************************************************************
 * APPLICATION IMPORTS
 */

 

蓝色和红色标注的有 import 内容是手工操作和注意的地方。

其中 两个依赖需要手工下载:

npm install --save classlist.js
npm install --save web-animations-js

最后下载完成后,再把import 前面的注释给去掉,我在执行 npm install --save web-animations-js 这句时,一直下载失败,就没有放出import(执行程序的时候并没有报错,也兼容IE了)。

 

完成上面的操作,执行 

ng serve --open

 

打开IE 输入:http://localhost:4200/dashboard

就可以在IE看到:

 
 

 

参考:https://blog.csdn.net/zmh458/article/details/80456968

 

  • 大小: 23.7 KB
分享到:
评论

相关推荐

    AngularJs兼容IE6-IE7-IE8

    项目需要、在网上查找angularjs支持ie低版本的问题(主要是windows7下只有IE8)整理了一个小demo 主要两点 1、ng-app="myApp" id="test11" 加上id="XXX" 加入以下代码注册到页面上 angular.element(document)....

    angular-file-upload-forie9

    对angular-file-upload源码进行修改,使之兼容ie9

    angularjs 兼容js

    angularjs兼容ie浏览器使用的js,包含.json3.min.js,respond.js, respond.min.js,html5shiv.min.js

    angular-file-upload 上传控件

    angular-file-upload 上传控件 封装成了一个用户控件。.net平台使用没有问题。不兼容IE低版本。

    关于angular浏览器兼容性问题的解决方案

    谷歌、火狐及-webkit-内核的浏览器均支持该属性(css3),IE不支持该属性,所以在IE中,会自动降级,表格无固定列,可滑动的形式。 Edge浏览器在1703之后的版本使用了chromium内核,对css3的属性支持较好,也支持...

    AngularJs IE Compatibility 兼容老版本IE

    如果我们打算让应用兼容IE8以及以下的版本,那么可以继续往下看。 二、Short Version(简述)  为了让我们的angular应用在IE上工作,请确保:  1. 按需引入JSON.stringify(IE7或以下的都需要这玩意)。我们可以...

    angular-modal-gallery:Angular的模态图像库

    @ ks89 / angular-modal-gallery是一个用于创建图像库的Angular库(与SSR兼容)。 尽管它的名称如此,但该库不仅仅用于模态画廊,因为我在每个主要版本中都引入了新功能。 实际上,它由3个主要部分组成: plain-...

    angular-notifier:针对Angular应用程序的精心设计,动画效果强,高度可自定义且易于使用的通知库

    如何安装您可以通过npm获取角度通知程序,方法是将其作为新的依赖项添加到package.json文件中,然后运行npm install或运行以下命令: npm install angular-notifier角度版本以下列表描述了与Angular的兼容性: 角度...

    nervjs-ie8:改写nervjs(React)兼容ie8的多页面框架

    nervjs-ie8 nervjs + react(可最新)+ cmui + html5 + css3 + less + es6 + webpack + axios + eslint +兼容IE8适合开发各种企业网站,后台管理系统,seo站点等等多页面应用cmui仓库为例如,亲信地铁(vueapp)腾讯...

    ngx-color-picker:纯Angular颜色选择器库

    兼容Angular 5+版本 无外部依赖 易于配置 易于使用 经过测试 Firefox(最新) 镀Chrome(最新) Chrome(最新) 边缘 IE11 安装/入门 npm install @iplab/ngx-color-picker --save 在您的应用模块内使用以下代码...

    angular-ui-layout

    =9,则需要使用 0.x 版用法你可以从得到它bower install angular-ui-layout \# bower# orbower install angular-ui-layout \# v0.0.0# orbower install angular-ui-layout \# src0.0.0 这将UI.Layout文件复制到一个...

    Angular中支持SCSS的方法

    SCSS 是 Sass 3 引入新的语法,其语法完全兼容 CSS3,并且继承了 Sass 的强大功能。也就是说,任何标准的 CSS3 样式表都是具有相同语义的有效的 SCSS 文件。另外,SCSS 还能识别大部分 CSS hacks(一些 CSS 小技巧)...

    AngularJS实现的鼠标拖动画矩形框示例【可兼容IE8】

    本文实例讲述了AngularJS实现的鼠标拖动画矩形框。分享给大家供大家参考,具体如下: <!DOCTYPE html> <... <... body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre

    Angular CLI在Angular项目中如何使用scss详解

    SCSS 是 Sass 3 引入新的语法,其语法完全兼容 CSS3,并且继承了 Sass 的强大功能。也就是说,任何标准的 CSS3 样式表都是具有相同语义的有效的 SCSS 文件。另外,SCSS 还能识别大部分 CSS hacks(一些 CSS 小技巧)...

    测试IE浏览器对JavaScript的AngularJS的兼容性

    为确保Angular应用在IE上能够工作请确认: 1. 在IE7或更早的版本上polyfill JSON.stringify。你可以使用JSON2或JSON3来polyfills。   <!doctype html> <html xmlns:ng="http://angularjs.org"> <...

    angular-litle

    0.0.4 - IE8 兼容性修复 0.0.3 - 返回 sendToLitle 调用的承诺。 贡献者 Joan Karla Comandante - IE8 修复了 Virginia Bustos - IE8 修复了 Roberta Bustos - 角度广播 Reginald Eli Deinla(原作者)

    angular2-shop:on在Angular 2上建立的一家高档,ReactSwift的小店

    这是基于Angular构建的精美,响应快速,跨浏览器兼容(IE11)商店/电子商务Web应用程序的实现。 演示: 特征 按名称,价格(asc)和价格(desc)对产品进行排序 通过产品名称即时搜索 按类别,价格范围,库存情况...

    angular-media-player:包装的AngularJS指令或者标签展示方法和属性来操纵您的播放器

    标记公开方法和属性来操纵播放器 github页面上的示例: : 弃用:开发停滞 该库的用户数量超出了我最初开发时的预期。 我对此感到非常高兴,但这意味着它具有我所期望的更高的贡献和测试要求! 从我可以看到的角度...

    视频WEB插件—适用于海康威视综合安防平台.rar

    Win7 32/64 位操作系统:32 位 IE10(兼容 64 位 IE10,64 位 IE10 环境下浏览器会默认启动 32 位 IE)、32/64 位 IE11、32/64 位 Chrome45.0 及以上版本、32/64 位 Firefox52.0 及以上版本 Win10 32/64 位操作系统...

Global site tag (gtag.js) - Google Analytics