Can't access property "removeEventListener" when destroy is called before swiper is mounted #6721
-
Hello I'm using swiper in nuxt. Sometimes I was getting the exception*:
The issue was that, when being initialized, swiper allows to be initialized for a class that doesn't exist yet in DOM without an exception. Then swiper can be mounted onto the element later. When destroying, it only checks if swiper instance exists and isn't destroyed. If swiper is never mounted, I'm not sure if
There's a similar issue #4043, but it didn't say anything conclusive * the exception happened because back button was clicked twice with suspense and for some reason nuxt didn't execute codesandbox reproduction example when html element exists
if element is deleted
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
export default defineNuxtPlugin((nuxtApp) => {
}) |
Beta Was this translation helpful? Give feedback.
-
Yes. It's been a while since I asked this question NuxtErrorBoundary can also be used to catch any swiper errors <script setup lang="ts">
const logSomeError = (e: unknown) => {
console.error("Swiper error", e);
};
</script>
<template>
<NuxtErrorBoundary @error="logSomeError">
<swiper
:slides-per-view="3"
:space-between="50"
>
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
</swiper>
</NuxtErrorBoundary>
</template> |
Beta Was this translation helpful? Give feedback.
export default defineNuxtPlugin((nuxtApp) => {