Skip to content

Commit 4ebb335

Browse files
author
郑飞杰
committed
触发update事件的时机优化成:事件update会在提交完成后执行,就算与上一次提交相同文件也会再次执行;用户取消提交、文件大小超过上限终止提交(error触发)都不会触发update
1 parent 3f06825 commit 4ebb335

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@
8383
allow-blob-url="是否输出Blob URL(true)"
8484
allow-base64="是否输出base64(true)"
8585
@error="文件大小超过上限回调的方法,带参数{ msg }"
86-
@update="input的change事件后改变了file的回调的方法,带参数{ file, blobUrl, base64 }"
86+
@update="input提交文件成功后回调的方法,带参数{ file, blobUrl, base64 }"
8787
/>
8888
```
89+
90+
>Tips:事件`update`会在提交完成后执行,就算与上一次提交相同文件也会再次执行;用户取消提交、文件大小超过上限终止提交(`error`触发)都不会触发`update`
8991
2. 插槽
9092
9193
```vue

dist/vue-input-file.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-input-file.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-input-file.iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
"rollup-plugin-vue": "5.0.1",
3636
"vue-template-compiler": "^2.6.10"
3737
},
38-
"version": "1.0.1"
38+
"version": "1.0.2"
3939
}

src/vue-input-file.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export default {
7474
} else {
7575
target.value = ''
7676
this.$emit('error', { msg: `上传文件过大(≈${(file.size / RATE).toFixed(1)}M),请上传${this.maxSize}M以下的图片` })
77-
this.update()
77+
// this.update()
7878
}
7979
} else {
80-
this.update()
80+
// this.update()
8181
}
8282
},
8383
handleReaderLoad (e) {
@@ -95,6 +95,8 @@ export default {
9595
this.base64 = base64
9696
9797
this.$emit('update', { file, blobUrl, base64 })
98+
99+
this.$refs.inputDom.value = ''
98100
},
99101
destroyReader () {
100102
this.reader.abort()

0 commit comments

Comments
 (0)