[Vuejs]-Computed Prop or Data to pass to style binding for Backgound Image

0👍

Using img tag in a laravel vue application, you don’t need to add the require() or @/assets/. Just use the path of the image or file as it is below

<img src="/image/test.jpg"/>

This will work just fine. For the case of your styling

<div :style="{ backgroundImage: 'url(' + imadata + ')' }">
data() {
    return { 
        imadata: "/images/cards/" + this.cardItem.image 
    };
 }

This will do the trick

Leave a comment