I have a span
that shows different background-image on different conditions.
HTML:
<span
v-if="type"
:style="styles"
>
</span>
In Computed:
styles() {
return {
"background-image": `url(${require(`../assets/images/${this.type}.png`)})`,
height: "30px",
width: "100%",
display: "block",
"background-size": "contain",
"background-repeat": "no-repeat",
"background-position": "center",
};
},
And I have another condition to show different background-image on mouseover
.
stylesOnHover() {
return {
"background-image": `url(${require(`../assets/images/${this.type}-hover.png`)})`
};
},
I tried to add
@mouseover="stylesOnHover"
in the HTML span but it shows error :
[Vue warn]: Error in v-on handler: "TypeError: handler.apply is not a function"
How can I change the background-image property on mouseover ? Thanks.