//图片下载
const getFilePic = (type) => {
return new Promise((resolve, reject) => {
const token = store.state.user.token;
axios
.request({
url: "http://192.168.31.54:82/company/getFile",
responseType: "blob",
method: "get",
headers: { Authorization: `Bearer ${token}` },
params: {
id: _id,
type: type ? type : typeUpload.value,
},
})
.then((res) => {
const blob = new Blob([res.data], { type: "image/png" });
const url = window.URL.createObjectURL(blob);
if (type === 1) imgUrl.loginLogo = url;
else imgUrl.logo = url;
resolve();
})
.catch(() => {
reject();
});
});
};
//上传
const handleUplo
Vue3中使用axios进行图片的上传和下载
最新推荐文章于 2024-05-17 15:55:05 发布
本文介绍在Vue3项目中,利用axios库实现图片的上传和下载功能。主要涉及的技术包括Vue3组件、antdVue的使用以及手动触发上传的实现细节。
摘要由CSDN通过智能技术生成