//responseType: 'blob' 记得设定好
export function blackNameexport(parkId) {
return request({
url: "/blackName/exportBlackName?parkId=" + parkId,
method: "get",
responseType: 'blob',
headers: {
userId: user_id,
},
});
}
//split("filename*=utf-8''")[1];是为了兼容后台命名,通常split("filename*=")[1];就行了
exportFile() {
let parkId = localStorage.getItem("Parking_ID");
blackNameexport(parkId).then((res) => {
//获取文件名
const fileName = res.headers['content-disposition'].split(';')[1].split("filename*=utf-8''")[1];
const filestream = res.data; // 返回的文件流
// {type: 'application/vnd.ms-excel'}指定对应文件类型为.XLS (.XLS的缩写就为application/vnd.ms-excel)
const blob = ne