解决ie兼容性问题

757 阅读1分钟

越来越多的公司开始使用fetch进行交互,但是由于是一门新技术,所以其兼容性有很多的问题,项目中该如何解决ie的兼容性问题呢:

引入 es6 的 polyfill: babel-polyfill 引入 promise 的 polyfill: es6-promise 引入 fetch 探测库:fetch-detector 引入 fetch 的 polyfill: fetch-ie8

安装执行

''' cnpm install babel-polyfill es6-promise fetch-detector fetch-ie8 --save '''

js 中引入

import 'babel-polyfill';

require('es6-promise').polyfill();

import 'fetch-detector';

import 'fetch-ie8';

注意: fetch-detector 一定要在 fetch-ie8 之前引入