愈來愈多的公司開始使用fetch進行交互,可是因爲是一門新技術,因此其兼容性有不少的問題,項目中該如何解決ie的兼容性問題呢:es6
引入 es6 的 polyfill: babel-polyfill 引入 promise 的 polyfill: es6-promise 引入 fetch 探測庫:fetch-detector 引入 fetch 的 polyfill: fetch-ie8npm
安裝執行promise
''' cnpm install babel-polyfill es6-promise fetch-detector fetch-ie8 --save '''babel
js 中引入fetch
import 'babel-polyfill';ui
require('es6-promise').polyfill();import
import 'fetch-detector';require
import 'fetch-ie8';兼容性
注意: fetch-detector 必定要在 fetch-ie8 以前引入cnpm