From dd660351d6abeaf749eebd7c859b279d213f508c Mon Sep 17 00:00:00 2001 From: bolingboling Date: Sat, 7 Dec 2019 17:58:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?upload-imgs:=20=E5=AE=9E=E7=8E=B0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0=E6=88=90=E5=8A=9F=E3=80=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=92=A9=E5=AD=90=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/base/upload-imgs/index.vue | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/base/upload-imgs/index.vue b/src/components/base/upload-imgs/index.vue index a4d23a01..131ef3bd 100644 --- a/src/components/base/upload-imgs/index.vue +++ b/src/components/base/upload-imgs/index.vue @@ -309,6 +309,16 @@ export default { type: Boolean, default: false, }, + /** 上传成功后的钩子 */ + onSuccess: { + type: Function, + default: () => {}, + }, + /** 上传失败后的钩子 */ + onError: { + type: Function, + default: () => {}, + }, }, computed: { /** 每项容器样式 */ @@ -621,8 +631,10 @@ export default { this.originUpload(item, data => { reduceResult(item, data) if (!data) { + this.onError(item) resolve(false) } else { + this.onSuccess(item) resolve(item) } }) @@ -1013,7 +1025,11 @@ export default { // 检测是否是动图 let isAnimated = null if (animatedCheck) { - isAnimated = await checkIsAnimated({ file, fileType, fileUrl: localSrc }) + isAnimated = await checkIsAnimated({ + file, + fileType, + fileUrl: localSrc, + }) } return new Promise((resolve, reject) => { let image = new Image() From a15a457e556f0d45d11af2ad1e7ac52b1ed33729 Mon Sep 17 00:00:00 2001 From: zhangxiaoshang Date: Mon, 9 Dec 2019 12:32:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?upload-imgs:=20=E5=9B=BE=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=88=90=E5=8A=9F=E3=80=81=E5=A4=B1=E8=B4=A5=E9=92=A9?= =?UTF-8?q?=E5=AD=90=E5=87=BD=E6=95=B0=E4=BD=BF=E7=94=A8=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/custom/views/Demo.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/custom/views/Demo.vue b/src/plugins/custom/views/Demo.vue index 9e3e6010..8f181f50 100644 --- a/src/plugins/custom/views/Demo.vue +++ b/src/plugins/custom/views/Demo.vue @@ -78,6 +78,9 @@
获取当前图像数据
+ + + @@ -224,6 +227,14 @@ export default { }) }, 3000) }, + handleSuccess(item) { + console.log('on-success', item) + this.$message.info('上传完成') + }, + handleError(item) { + console.log('on-error', item) + this.$message.info('上传失败') + }, }, }