Reactjs Axios IE 11问题,无法下载响应类型blob

Reactjs Axios IE 11问题,无法下载响应类型blob,reactjs,internet-explorer,axios,Reactjs,Internet Explorer,Axios,但它不是下载“你想让这个网站在你的电脑上打开一个应用程序吗?”而是使用谷歌浏览器和mozilla firefox。就我所知,这款浏览器不支持IE浏览器,急需帮助。因此,在IE和Edge浏览器中,在获取文件数据后,您可以使用msSaveOrOpenBlob方法在IE和Edge浏览器中下载文件,在Chrome或Firefox浏览器中,您可以创建超链接以使用URL下载文件。更多详细信息,请查看此示例: axios.get("http://localhost:63542/api/v1/WorkInst"

但它不是下载“你想让这个网站在你的电脑上打开一个应用程序吗?”而是使用谷歌浏览器和mozilla firefox。就我所知,这款浏览器不支持IE浏览器,急需帮助。因此,在IE和Edge浏览器中,在获取文件数据后,您可以使用msSaveOrOpenBlob方法在IE和Edge浏览器中下载文件,在Chrome或Firefox浏览器中,您可以创建超链接以使用URL下载文件。更多详细信息,请查看此示例:

axios.get("http://localhost:63542/api/v1/WorkInst",
            {
                responseType: 'arraybuffer',
                headers: {
                    'Content-Type': 'application/json',
                    'Accept': 'application/pdf'
                }
            })
            .then((response) => {
                console.log(response);
                var blob = new Blob([response.data], {type: 'application/pdf'});
                var downloadUrl = URL.createObjectURL(blob);
                var a = document.createElement("a");
                a.href= downloadUrl;
                a.download = ("test.pdf");
                a.click();


            })
            .catch((error) => console.log(error));
        if (window.navigator && window.navigator.msSaveOrOpenBlob) {
            //IE11 and the legacy version Edge support
            console.log("IE & Edge");
            let blob = new Blob([data], { type: "text/html" });
            window.navigator.msSaveOrOpenBlob(blob, fileName);
        } else {// other browsers
            console.log("Other browsers");
            var bl = new Blob([data], { type: "text/html" });
            var a = document.createElement("a");
            a.href = URL.createObjectURL(bl);
            a.download = fileName;
            a.hidden = true;
            document.body.appendChild(a);
            a.click();
        }