<a-upload v-model:file-list="fileList" accept:".pdf,.png" action="https://www.mocky.io/v2/5cc8019d300000980a055e76" :before-upload="beforeUpload" @change="handleChange" withCredentials > <a-button> <upload-outlined></upload-outlined> Upload png only </a-button> </a-upload>
const handleChange = ({ file, fileList }) => {
const fileList = file.fileList;
fileList.forEach(item=>{
if(item.status!== 'uploading'){
files.value.push(item.response?.data)
}
})
} };
const beforeUpload = file => {
const isPNG = file.type === 'image/png';
if (!isPNG) { message.error(`${file.name} is not a png file`); }
return isPNG || Upload.LIST_IGNORE;
if(fileLists.value.length+fileList.length>5){
message.error("最多上传5个附件")
}
};