From 9a419b91dbb35667963aa512b1bdb00a738ec586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 14 Jun 2022 11:29:10 +0300 Subject: [PATCH] Fixed #2661 - New Image error event --- api-generator/components/image.js | 4 ++++ src/components/image/Image.d.ts | 6 ++++++ src/components/image/Image.vue | 3 ++- src/views/image/ImageDoc.vue | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api-generator/components/image.js b/api-generator/components/image.js index b7643278f..f486b2c84 100644 --- a/api-generator/components/image.js +++ b/api-generator/components/image.js @@ -15,6 +15,10 @@ const ImageEvents = [ { name: "hide", description: "Triggered when the preview overlay is hidden." + }, + { + name: "error", + description: "Triggered when an error occurs while loading an image file." } ]; diff --git a/src/components/image/Image.d.ts b/src/components/image/Image.d.ts index 632d67724..928459bf0 100644 --- a/src/components/image/Image.d.ts +++ b/src/components/image/Image.d.ts @@ -39,6 +39,12 @@ declare class Image extends ClassComponent { * @memberof Image */ hide: () => void; + /** + * Triggered when an error occurs while loading an image file. + * + * @memberof Image + */ + error: () => void; } declare module '@vue/runtime-core' { diff --git a/src/components/image/Image.vue b/src/components/image/Image.vue index 1e2a1f5e1..7e4461838 100644 --- a/src/components/image/Image.vue +++ b/src/components/image/Image.vue @@ -42,6 +42,7 @@ import Portal from 'primevue/portal'; export default { name: 'Image', inheritAttrs: false, + emits: ['show', 'hide', 'error'], props: { preview: { type: Boolean, @@ -94,7 +95,7 @@ export default { this.previewClick = false; }, onError() { - this.$emit('onError'); + this.$emit('error'); }, rotateRight() { this.rotate += 90; diff --git a/src/views/image/ImageDoc.vue b/src/views/image/ImageDoc.vue index 5b6b20acf..882dcd54b 100644 --- a/src/views/image/ImageDoc.vue +++ b/src/views/image/ImageDoc.vue @@ -90,6 +90,11 @@ import Image from 'primevue/image'; hide - Triggered when the preview overlay is hidden. + + + error + - + Triggered when an error occurs while loading an image file.