Fixed #2661 - New Image error event

pull/2663/head
Tuğçe Küçükoğlu 2022-06-14 11:29:10 +03:00
parent cdf42edd14
commit 9a419b91db
4 changed files with 17 additions and 1 deletions

View File

@ -15,6 +15,10 @@ const ImageEvents = [
{ {
name: "hide", name: "hide",
description: "Triggered when the preview overlay is hidden." description: "Triggered when the preview overlay is hidden."
},
{
name: "error",
description: "Triggered when an error occurs while loading an image file."
} }
]; ];

View File

@ -39,6 +39,12 @@ declare class Image extends ClassComponent<ImageProps, ImageSlots, ImageEmits> {
* @memberof Image * @memberof Image
*/ */
hide: () => void; hide: () => void;
/**
* Triggered when an error occurs while loading an image file.
*
* @memberof Image
*/
error: () => void;
} }
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {

View File

@ -42,6 +42,7 @@ import Portal from 'primevue/portal';
export default { export default {
name: 'Image', name: 'Image',
inheritAttrs: false, inheritAttrs: false,
emits: ['show', 'hide', 'error'],
props: { props: {
preview: { preview: {
type: Boolean, type: Boolean,
@ -94,7 +95,7 @@ export default {
this.previewClick = false; this.previewClick = false;
}, },
onError() { onError() {
this.$emit('onError'); this.$emit('error');
}, },
rotateRight() { rotateRight() {
this.rotate += 90; this.rotate += 90;

View File

@ -90,6 +90,11 @@ import Image from 'primevue/image';
<td>hide</td> <td>hide</td>
<td>-</td> <td>-</td>
<td>Triggered when the preview overlay is hidden.</td> <td>Triggered when the preview overlay is hidden.</td>
</tr>
<tr>
<td>error</td>
<td>-</td>
<td>Triggered when an error occurs while loading an image file.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>