🐛(upload): 修复 upload 组件连续选择两个相同文件无法触发上传的问题

This commit is contained in:
就眠儀式 2022-10-31 22:27:56 +08:00
parent 2600e6756f
commit 45746111b8
2 changed files with 6 additions and 4 deletions

View File

@ -234,7 +234,7 @@ const errorF = (errorText: string) => {
};
const localUpload = (option: localUploadOption, callback: Function) => {
let xhr: XMLHttpRequest, loadedevt, total, per: number, url, uploading;
let xhr: XMLHttpRequest, url;
xhr = new XMLHttpRequest();
url = option.url;
let formData = option.formData;
@ -279,6 +279,7 @@ const localUpload = (option: localUploadOption, callback: Function) => {
if (cb && typeof cb == "function") {
cb();
}
(orgFileInput.value as HTMLInputElement).value = "";
};
const filetoDataURL = (file: File, fn: Function) => {

View File

@ -13,7 +13,7 @@
::: demo 使用 `lay-upload` 标签, 创建一个上传按钮
<template>
<lay-upload @done="getUploadFile" field="bigFile" @choose="beginChoose">
<lay-upload url="https://www.mocky.io/v2/5cc8019d300000980a055e76" @done="doneHandle" field="bigFile" @choose="beginChoose">
<template #preview>
<div v-for="(item,index) in picList" :key="`demo1-pic-'${index}`">
<img :src="item"/>
@ -35,7 +35,8 @@ export default {
};
reader.readAsDataURL(file);
};
const getUploadFile=(files)=>{
const doneHandle=(files)=>{
console.log("触发")
if(Array.isArray(files)&&files.length>0){
files.forEach((file,index,array)=>{
filetoDataURL(file,(res)=>{
@ -50,7 +51,7 @@ export default {
console.log("beginChoose",e);
};
    return {
getUploadFile,
doneHandle,
filetoDataURL,
beginChoose,
picList