Skip to content

Commit a79fc71

Browse files
feat(nuxt): emit error event (closes #42)
1 parent ec605f9 commit a79fc71

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/nuxt/src/runtime/components/UnLazyImage.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const props = withDefaults(
6666
6767
const emit = defineEmits<{
6868
(event: 'loaded', image: HTMLImageElement): void
69+
(event: 'error', error: Event): void
6970
}>()
7071
7172
const unlazy = useRuntimeConfig().public.unlazy as ModuleOptions
@@ -145,6 +146,7 @@ onBeforeUnmount(() => {
145146
:data-srcset="srcSet"
146147
:data-sizes="autoSizes ? 'auto' : undefined"
147148
loading="lazy"
149+
@error="emit('error', $event)"
148150
>
149151
</picture>
150152
<img
@@ -156,5 +158,6 @@ onBeforeUnmount(() => {
156158
:data-srcset="srcSet"
157159
:data-sizes="autoSizes ? 'auto' : undefined"
158160
loading="lazy"
161+
@error="emit('error', $event)"
159162
>
160163
</template>

0 commit comments

Comments
 (0)