axios IE 承诺不起作用 [英] axios IE promise doesn't work

查看:25
本文介绍了axios IE 承诺不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 axios 进行 ajax 通信.我的 IE 有问题.IE 返回关于 Promise 的错误.IE 对 Promise 一无所知.

I am using axios for ajax communication. I have problem with IE. IE return error about Promise. IE doesn't know anything about Promise.

我正在编写 react/redux,但我在普通 JS 中尝试了 axios 并且结果相同

I am writing react/redux but I tried axios in plain JS and same result

有人可以帮我吗?我很困惑,因为 axios 应该适用于 IE 8+我试过 IE 11 (windows 10 64bit)

Could someone help me with it? I am confused because axios should work on IE 8+ I tried on IE 11 (windows 10 64bit)

我的试用版是按 axios 主页上的示例编写的

My trial is written as is in example on axios homepage

谢谢

推荐答案

如果浏览器没有 promise 实现,你必须包含一个 promise polyfill.这听起来很复杂,但确实有很好的库.

You have to include a promise polyfill if the browser has no promise implementation. This sounds complicated but there are really good libs.

axios 文档提到了它:axios 依赖于要支持的原生 ES6 Promise 实现.如果您的环境不支持 ES6 Promises,您可以使用 polyfill.

The axios docs mention it: axios depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.

如果您只使用 JS 而不进行转译或捆绑,您可以尝试 es6-promise

If you use just JS without transpiling or bundling you can try es6-promise

或者如果你使用 babel 你可以使用 它的 polyfill

or if you use babel you can take its polyfill

这篇关于axios IE 承诺不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆