🐛(upload): 修复 upload 组件连续选择两个相同文件无法触发上传的问题
This commit is contained in:
parent
2600e6756f
commit
45746111b8
@ -234,7 +234,7 @@ const errorF = (errorText: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const localUpload = (option: localUploadOption, callback: Function) => {
|
const localUpload = (option: localUploadOption, callback: Function) => {
|
||||||
let xhr: XMLHttpRequest, loadedevt, total, per: number, url, uploading;
|
let xhr: XMLHttpRequest, url;
|
||||||
xhr = new XMLHttpRequest();
|
xhr = new XMLHttpRequest();
|
||||||
url = option.url;
|
url = option.url;
|
||||||
let formData = option.formData;
|
let formData = option.formData;
|
||||||
@ -279,6 +279,7 @@ const localUpload = (option: localUploadOption, callback: Function) => {
|
|||||||
if (cb && typeof cb == "function") {
|
if (cb && typeof cb == "function") {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
(orgFileInput.value as HTMLInputElement).value = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const filetoDataURL = (file: File, fn: Function) => {
|
const filetoDataURL = (file: File, fn: Function) => {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
::: demo 使用 `lay-upload` 标签, 创建一个上传按钮
|
::: demo 使用 `lay-upload` 标签, 创建一个上传按钮
|
||||||
|
|
||||||
<template>
|
<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>
|
<template #preview>
|
||||||
<div v-for="(item,index) in picList" :key="`demo1-pic-'${index}`">
|
<div v-for="(item,index) in picList" :key="`demo1-pic-'${index}`">
|
||||||
<img :src="item"/>
|
<img :src="item"/>
|
||||||
@ -35,7 +35,8 @@ export default {
|
|||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
};
|
};
|
||||||
const getUploadFile=(files)=>{
|
const doneHandle=(files)=>{
|
||||||
|
console.log("触发")
|
||||||
if(Array.isArray(files)&&files.length>0){
|
if(Array.isArray(files)&&files.length>0){
|
||||||
files.forEach((file,index,array)=>{
|
files.forEach((file,index,array)=>{
|
||||||
filetoDataURL(file,(res)=>{
|
filetoDataURL(file,(res)=>{
|
||||||
@ -50,7 +51,7 @@ export default {
|
|||||||
console.log("beginChoose",e);
|
console.log("beginChoose",e);
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
getUploadFile,
|
doneHandle,
|
||||||
filetoDataURL,
|
filetoDataURL,
|
||||||
beginChoose,
|
beginChoose,
|
||||||
picList
|
picList
|
||||||
|
Loading…
Reference in New Issue
Block a user