'how to data bind src attribute of img tag in vue3 while using v-for
the require() is causing the following error: Compiled with problems:X
ERROR in ./src/assets/images/index.html 1:0
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
<template v-for="product in productsData" v-bind:key = "product.name" >
<div class="col-lg-4 col-md-6 wow animate__animated animate__fadeInUp" data-wow-delay="0.1s">
<div class="property-item rounded overflow-hidden">
<div class="position-relative overflow-hidden">
<router-link to=''><img class="img-fluid" v-bind:src="require('@/assets/images/'+ product.image)" alt="Product Image"></router-link>
<div class="bg-primary rounded text-white position-absolute start-0 top-0 m-4 py-1 px-3">{{ product.price }}</div>
<div class="bg-white rounded-top text-primary position-absolute start-0 bottom-0 mx-4 pt-1 px-3">{{ product.name }}</div>
</div>
<div class="p-4 pb-0">
<h5 class="text-primary mb-3">${{ product.lotteryPrice }}</h5>
<a class="d-block h5 mb-2" href="">Golden Urban House For Sell</a>
<router-link to='/registration' class="btn btn-outline-primary mb-3"><i class="fa fa-play text-primary me-2"></i>Play Now</router-link>
</div>
<div class="d-flex border-top">
<small class="flex-fill text-center border-end py-2"><i class="fa fa-ruler-combined text-primary me-2"></i>1000 Sqft</small>
<small class="flex-fill text-center border-end py-2"><i class="fa fa-bed text-primary me-2"></i>3 Bed</small>
<small class="flex-fill text-center py-2"><i class="fa fa-bath text-primary me-2"></i>2 Bath</small>
</div>
</div>
</div>
</template>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
