React Fetch在IE11中不起作用 [英] React Fetch not working in IE11
问题描述
我有一个ReactJS应用程序在Chrome中按预期工作,但在IE-11中失败。
I have a ReactJS application that works as expected in Chrome, but fails in IE-11.
问题是这个 - 我们有两个下拉列表是首次加载页面时从休息服务填充。该应用程序在SSL下运行。当页面通过IE-11加载时,我得到一个IE-11错误问题,其中第一个请求调用被第二个请求调用取消 - 这里描述了错误:
The problem is this - we have two drop down lists which are populated from rest services when the page is first loaded. The application is running under SSL. When the page is loaded through IE-11, I get an IE-11 bug issue where the first request call gets cancelled out by the second-the bug is described here:
https://developer.microsoft.com/en-us / microsoft-edge / platform / issues / 1282036 /
所以,我只是问社区IE-11是否有解决方法或是在那里顺序实现我的代码,如果第一个完成则调用第二个:
So, I am just asking the community whether there is a work around for IE-11 or is there away to implement my code sequentially where if the first is complete the second is called:
export let getMainData = (dtType, url)=> {
return dispatch=>{
dispatch(sendGet(dtType));
const action = (async(url) => {
const response = await fetch(url);
let data = await response.json();
dispatch(receiveGet(dtType,data));
});
action(url);
};
};
上面的代码是公共代码,其他人在React App中使用。那么我想是否有一个抽象级别,两个下拉列表可以顺序调用,然后调用上面的下面,也许?
The code above is common code and is used by others in the React App. So what I am thinking if there is away to have a level of abstraction where the two drop down lists can call sequentially and then call the above underneath, perhaps?
推荐答案
只需将 isomorphic-fetch
作为polyfill包含在不受支持的浏览器中。
Just include isomorphic-fetch
as polyfill to make it work on unsupported browsers.
https://github.com/matthew-andrews/isomorphic-fetch
这篇关于React Fetch在IE11中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!