记录一下今天使用组件遇到的问题——多次调用on-change
因为他在点击上传和成功或者失败的时候都会调用,当是上传成功时,status===ready,所以在执行之前加一个判断就可以了,我的是成功上传时再执行,代码如下:
if (e.status === 'ready'){
const pddss = new FormData();
pddss.append("img", e.raw, e.name);
console.log(pddss);
axios({
method: 'post',
url: "https://scienicpc.kuxia.top/pcapi/File/fileimg",
data: pddss
}).then(res => {
console.log(res);
fileList.value.push({ name: 'abc.png', url: "https://scienicpc.kuxia.top" + res.data.front_file })
console.log(fileList);
})
}