mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Uploader): multiple reupload only choose one & cancel choose problem (#12359)
* fix(Uploader): multiple reupload only choose one & cancel chose problem * fix(Uploader): multiple reupload only choose one & cancel chose problem * fix(Uploader): refactor code * fix(Uploader): refactor code
This commit is contained in:
parent
1219e4386c
commit
6f74d77da9
@ -5,6 +5,7 @@ import {
|
|||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
type PropType,
|
type PropType,
|
||||||
type ExtractPropTypes,
|
type ExtractPropTypes,
|
||||||
|
nextTick,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
@ -104,6 +105,7 @@ export default defineComponent({
|
|||||||
const inputRef = ref();
|
const inputRef = ref();
|
||||||
const urls: string[] = [];
|
const urls: string[] = [];
|
||||||
const reuploadIndex = ref(-1);
|
const reuploadIndex = ref(-1);
|
||||||
|
const isReuploading = ref(false);
|
||||||
|
|
||||||
const getDetail = (index = props.modelValue.length) => ({
|
const getDetail = (index = props.modelValue.length) => ({
|
||||||
name: props.name,
|
name: props.name,
|
||||||
@ -278,9 +280,15 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const reuploadImage = (index: number) => {
|
const reuploadImage = (index: number) => {
|
||||||
// eslint-disable-next-line no-use-before-define
|
isReuploading.value = true;
|
||||||
chooseFile();
|
|
||||||
reuploadIndex.value = index;
|
reuploadIndex.value = index;
|
||||||
|
nextTick(() => chooseFile());
|
||||||
|
};
|
||||||
|
const onInputClick = () => {
|
||||||
|
if (!isReuploading.value) {
|
||||||
|
reuploadIndex.value = -1;
|
||||||
|
}
|
||||||
|
isReuploading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderPreviewItem = (item: UploaderFileListItem, index: number) => {
|
const renderPreviewItem = (item: UploaderFileListItem, index: number) => {
|
||||||
@ -344,6 +352,7 @@ export default defineComponent({
|
|||||||
multiple={props.multiple && reuploadIndex.value === -1}
|
multiple={props.multiple && reuploadIndex.value === -1}
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onClick={onInputClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user