Skip to content

Commit df595a2

Browse files
committed
1 parent 982ee34 commit df595a2

File tree

4 files changed

+23
-341
lines changed

4 files changed

+23
-341
lines changed

src/FileUpload.vue

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<template>
22
<span :class="className">
33
<slot></slot>
4-
<label :for="forId"></label>
4+
<label :for="forId"></label>
55
<input
6-
ref="input"
7-
type="file"
8-
:name="name"
9-
:id="forId"
10-
:accept="accept"
11-
:capture="capture"
12-
:disabled="disabled"
13-
:webkitdirectory="directory && features.directory"
14-
:allowdirs="directory && features.directory"
15-
:directory="directory && features.directory"
16-
:multiple="multiple && features.html5"
17-
@change="inputOnChange"
18-
/>
6+
v-if="!reload"
7+
ref="input"
8+
type="file"
9+
:name="name"
10+
:id="forId"
11+
:accept="accept"
12+
:capture="capture"
13+
:disabled="disabled"
14+
:webkitdirectory="directory && features.directory"
15+
:allowdirs="directory && features.directory"
16+
:directory="directory && features.directory"
17+
:multiple="multiple && features.html5"
18+
@change="inputOnChange"
19+
/>
1920
</span>
2021
</template>
2122
<style>
@@ -51,7 +52,7 @@
5152
}
5253
</style>
5354
<script lang="ts">
54-
import {PropType, defineComponent} from "vue";
55+
import {PropType, defineComponent, h} from "vue";
5556
5657
// @ts-ignore
5758
import ChunkUploadDefaultHandler from './chunk/ChunkUploadHandler.js'
@@ -82,6 +83,7 @@ export interface Data {
8283
uploading: number;
8384
features: Features;
8485
dropElement: null | HTMLElement;
86+
reload: boolean;
8587
}
8688
8789
export interface Features {
@@ -318,6 +320,7 @@ export default defineComponent({
318320
destroy: false,
319321
maps: {},
320322
dropElement: null,
323+
reload: false,
321324
}
322325
},
323326
/**
@@ -1570,23 +1573,11 @@ export default defineComponent({
15701573
}
15711574
const target = e.target
15721575
const reinput = (res: any) => {
1573-
if (target.files) {
1574-
target.value = ''
1575-
if (target.files.length && !/safari/i.test(navigator.userAgent)) {
1576-
target.type = ''
1577-
target.type = 'file'
1578-
}
1579-
} else {
1580-
// ie9 fix #219
1581-
const oldInput = document.getElementById(this.forId) as HTMLInputElement
1582-
const newInput = oldInput.cloneNode(true) as HTMLInputElement
1583-
newInput.value = ''
1584-
newInput.type = 'file'
1585-
// @ts-ignore
1586-
newInput.onChange = this.inputOnChange
1587-
oldInput.parentNode?.replaceChild(newInput, oldInput)
1588-
this.$refs.input = newInput
1589-
}
1576+
this.reload = true
1577+
// @ts-ignore
1578+
this.$nextTick(() => {
1579+
this.reload = false
1580+
})
15901581
return res
15911582
}
15921583

src/FileUpload.vue.d.ts

Lines changed: 0 additions & 307 deletions
This file was deleted.

src/InputFile.vue

Whitespace-only changes.

0 commit comments

Comments
 (0)