“Content-Type”: “application/json”,
Authorization: ‘token’ // 拿项目本地的token
}
})
.then(content => {
const blob = new Blob([content]);// content 这里要和后台确认可能会多包裹一层
const a = document.createElement(“a”);
const url = window.URL.createObjectURL(blob);
const filename = fileName + suffix;
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
// 释放URL 对象
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
})
}
页面中使用: