QCarousel slide - use img onerror event attribute

  • Hi,
    is there any way, how use img tag event attribute onerror with Carousel slide component?

    I have Carousel with images. All images are saved in the cloud. I want to show on the slide default static image, if will be not possible load original image from the server.

  • I’m assuming you are using the img-src prop on the q-carousel-slide component like this:

    <q-carousel-slide :name="1" img-src="https://cdn.quasar.dev/img/mountains.jpg" />

    You could do this instead to archieve something similar:

    <q-carousel-slide name="1" class="q-pa-none">
         <img src="https://cdn.quasar.dev/img/mountains.jpg" alt="mountains" class="fit" style="object-fit: cover;">

    So that you can add your onerror-listener to the<img> tag yourself.

    Note the q-pa-none class on the q-carousel-slide and the q-carousel should probably not have the padding prop

Log in to reply