【发布时间】:2020-10-13 14:42:43
【问题描述】:
我有一个post方法
uploadFile: async function () {
const formData = new FormData();
formData.append("file", this.file);
let url = `http://...`;
try {
this.source = axios.CancelToken.source();
const res = await axios.post(url, formData, {
headers: {
Authorization: "Token " + this.$store.getters.getToken,
"Content-Type": "multipart/form-data",
},
cancelToken: this.source.token,
});
} catch (error) {
}
}
和取消方法
cancelLoad: function () {
this.source.cancel('cancel upload');
},
【问题讨论】:
-
“文件已加载”到底是什么意思?
-
@tony19 文件已上传,我可以从后端获取
标签: javascript vue.js vuejs2 axios