diff --git a/docs/docs/en.md b/docs/docs/en.md index f26e7b1..2c0b0d5 100644 --- a/docs/docs/en.md +++ b/docs/docs/en.md @@ -618,9 +618,12 @@ Add, update, remove pre-filter If the `oldFile` value is `undefined` 'is added If `newFile`, `oldFile` is exist, it is updated + > Synchronization modify `newFile` + > Asynchronous Please use `update`,` add`, `remove`,` clear` method + > Asynchronous Please set an error first to prevent being uploaded - > You can not use `update`,` add`, `remove`,` clear` methods in the event - >The `newFile` object can be modified within the event + > Synchronization can not use `update`,` add`, `remove`,` clear` methods + > Asynchronous can not modify `newFile` * **Usage:** ```html @@ -717,11 +720,6 @@ Add, update, remove after inputFile(newFile, oldFile) { if (newFile && !oldFile) { // Add file - - // Automatic upload - if (!this.$refs.upload.active) { - this.$refs.upload.active = true - } } if (newFile && oldFile) { @@ -764,6 +762,13 @@ Add, update, remove after // }); } } + + // Automatic upload + if (Boolean(newFile) !== Boolean(oldFile) || oldFile.error !== newFile.error) { + if (!this.$refs.upload.active) { + this.$refs.upload.active = true + } + } } } } diff --git a/docs/docs/zh-cn.md b/docs/docs/zh-cn.md index 792e8c3..7b09a56 100644 --- a/docs/docs/zh-cn.md +++ b/docs/docs/zh-cn.md @@ -612,8 +612,13 @@ Add, update, remove pre-filter 如果 `oldFile` 值为 `undefined` 则是添加 如果 `newFile`, `oldFile` 都存在则是更新 - > 事件内不可使用 `update`, `add`, `remove`, `clear` 方法 - 事件内可修改 `newFile` 对象 + > 事件内同步处理请直接修改 `newFile` + > 事件内异步处理请使用 `update`, `add`, `remove`, `clear` 方法 + > 异步请先设置一个错误以防止被上传 + + > 同步不能使用 `update`, `add`, `remove`, `clear` 方法 + > 异步不能修改 `newFile` + * **示例:** ```html @@ -709,11 +714,6 @@ Add, update, remove pre-filter inputFile(newFile, oldFile) { if (newFile && !oldFile) { // 添加文件 - - // 自动上传 - if (!this.$refs.upload.active) { - this.$refs.upload.active = true - } } if (newFile && oldFile) { @@ -756,6 +756,13 @@ Add, update, remove pre-filter // }); } } + + // 自动上传 + if (Boolean(newFile) !== Boolean(oldFile) || oldFile.error !== newFile.error) { + if (!this.$refs.upload.active) { + this.$refs.upload.active = true + } + } } } } diff --git a/docs/views/examples/Full.vue b/docs/views/examples/Full.vue index 82d6d16..bc4e421 100644 --- a/docs/views/examples/Full.vue +++ b/docs/views/examples/Full.vue @@ -59,12 +59,12 @@ Action
+