获得徽章 0
赞了这篇沸点
每日有感:
后端返回byte[]字节流前端获取后保存为文件下载到本地原生代码
var xhr = new XMLHttpRequest(); //要请求的Url和携带的参数
var url=`xxxxx`;
xhr.open("get", url, true);//打开请求
//设置响应类型为blob类型(接受字节流)
xhr.responseType = "blob";
const aDom = document.createElement('a');
xhr.onload = function () {//返回成功之后执行的方法
if (this.status == "200") { // 获取响应文件流
var blob = this.response; // 将文件流保存到a标签
aDom.href = window.URL.createObjectURL(blob)
aDom.download = 'zzz.txt';
};
aDom.click();
}
xhr.send();//发送请求
简而言之,
1.更改responseType 为'blod'用blod的方式接受数据
2.转换blod
3.用a标签将转换好的文件下载下来
后端返回byte[]字节流前端获取后保存为文件下载到本地原生代码
var xhr = new XMLHttpRequest(); //要请求的Url和携带的参数
var url=`xxxxx`;
xhr.open("get", url, true);//打开请求
//设置响应类型为blob类型(接受字节流)
xhr.responseType = "blob";
const aDom = document.createElement('a');
xhr.onload = function () {//返回成功之后执行的方法
if (this.status == "200") { // 获取响应文件流
var blob = this.response; // 将文件流保存到a标签
aDom.href = window.URL.createObjectURL(blob)
aDom.download = 'zzz.txt';
};
aDom.click();
}
xhr.send();//发送请求
简而言之,
1.更改responseType 为'blod'用blod的方式接受数据
2.转换blod
3.用a标签将转换好的文件下载下来
展开
4
2
赞了这篇沸点
赞了这篇沸点
赞了这篇文章
赞了这篇沸点
感恩节,我要感谢社会的毒打让我能披荆斩棘的活到现在,要感谢朋友的冷漠和嘲讽,让我看清了所有事,万事不烦心,感谢教过我的老师,反正学的东西都还回去了,感谢每一个我买过东西的店铺老板,毕竟我留下过我支付宝支付的信息,也算雁过拔毛了,感谢错过的每一个富婆,让我理解了打工人的真谛,感恩节,感谢有你们
评论
4
赞了这篇沸点
赞了这篇文章
赞了这篇沸点
关于宏任务、微任务以及事件轮询机制的一道面试题!
闲来摸鱼的瞅瞅看
async function asyncA() {
console.log("1");
await asyncB();
console.log("2");
}
async function asyncB() {
console.log("3");
}
console.log("4");
setTimeout(() => {
console.log("5");
Promise.resolve().then(function () {
console.log("6");
});
}, 0);
setTimeout(() => {
console.log("7");
Promise.resolve().then(function () {
console.log("8");
});
}, 0);
asyncA();
new Promise(function (resolve) {
console.log("9");
resolve();
}).then(function () {
console.log("10");
});
console.log("11");
闲来摸鱼的瞅瞅看
async function asyncA() {
console.log("1");
await asyncB();
console.log("2");
}
async function asyncB() {
console.log("3");
}
console.log("4");
setTimeout(() => {
console.log("5");
Promise.resolve().then(function () {
console.log("6");
});
}, 0);
setTimeout(() => {
console.log("7");
Promise.resolve().then(function () {
console.log("8");
});
}, 0);
asyncA();
new Promise(function (resolve) {
console.log("9");
resolve();
}).then(function () {
console.log("10");
});
console.log("11");
展开
15
7
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇沸点
赞了这篇文章