Well, this component doesn't seem to provide this particular event handler (at the time of writing), but you could add a ref
on the component and register the error handler on mounted
hook:
<b-card overlay
:title="name"
:sub-title="description"
:img-src="cardImg"
img-top
style="max-width: 20rem;"
class="mb-2"
ref="card">
</b-card>
new Vue({
el: '#app',
mounted() {
this.$refs.card.querySelector('img').onerror = this.handleImgError;
},
methods: {
handleImgError(evt) {
// event has all the error info you will need
// evt.type = 'error';
}
}
});
Or actually, create a wrapper component providing one.
./components/Card.vue
<template>
<b-card
overlay
:title="name"
:sub-title="description"
:img-src="cardImg"
img-top
style="max-width: 20rem;"
class="mb-2">
</b-card>
</template>
<script>
import bCard from "bootstrap-vue/es/components/card/card";
export default {
name: "Card",
mounted() {
this.$el.querySelector("img").onerror = e => {
this.$emit('onerror', e);
};
},
components: {
bCard
}
};
</script>
index.html
<div id="app">
<card @onerror="handleImgError"></card>
</div>