angular项目兼容IE浏览器

前言

图书馆的项目最近想要放到钉钉上使用,但是项目放到微信公众号上可以访问,放到钉钉上却不可以用,刚开始很疑惑为什么会这样呢,后来才知道钉钉的内核是IE内核,把项目放到电脑上的IE浏览器中也是不可以访问的。知道了为什么,接下来就好办了,那就是解决呗。

叙述

其实angular项目如何兼容IE浏览器,项目中已经告诉我们了,打开angular自动生成polyfill.ts文件,你可以看到这样的内容

/*************************************************************************************************** * 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';
  import 'babel-polyfill';
 import 'classlist.js';
 import 'web-animations-js';
/** 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 to support `@angular/animation`. */
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

/** ALL Firefox browsers require the following to support `@angular/animation`. **/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

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

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

/** * Date,currency,decimal and percent pipes. * Needed for: All but Chrome,Firefox,Edge,IE11 and Safari 10 */
// import 'intl'; // Run `npm install --save intl`.

对于文件中import在干什么,你仔细看每一行代码后面的注释就知道了。解释的非常的详细。
这里有一个小注意点,有两个依赖需要你手动安装:
npm install –save classlist.js
npm install –save web-animations-js
文件中过的这两个引用打开,然后进行安装,就可以在IE浏览器中访问了。

小结

很简单的解决方法,一定要去尝试哦。

感谢您的阅读~~

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...