1,各个浏览器对fetch的支持情况 :http://caniuse.com/#search=fetch
原因:Proimse在低版本上的支持问题,
解决方案: 手动写个文件引入pinkie-promise,判断当前是否有window.Promise,如果没有就把我引入的作为window.Promise.、
实施步骤:(react + webpack项目为例)
1,添加 whatwg-fetch模块
npm install whatwg-fetch -save
2,由于 whatwg-fetch模块没有pinkie-promise,因此需要在模块内引入
cd /node_modules/whatwg-fetch
npm install pinkie-fetch --save
3,在自己的数据请求模块,引入使用whatwg-fetch
4,这样封装使用请求,就会兼容大部分手机浏览器(通过手机UC浏览器测试)
浏览文章: