1

How can I bind the prod.src?

<v-row>
    <v-col v-for="prod in products" :key="prod.id" cols="12" md="6" lg="3">

          <v-btn outline block class="primary">{{prod.id}}</v-btn>                   
          <img :src="require(`${prod.src}`)" />     <!-- I was trying this -->

    </v-col>        
</v-row>

<script>
   export default {
      data: () => ({
        products: [         
           { id: 1112, src: "https://freeimage1.jpg" },        
           { id: 1113, src: "https://freeimage2.jpg" },   
         ]
     }),    
  };
</script>    

Chrome console shows an error: Cannot find module 'https://freeimage1.jpg'

3
  • 2
    did you tried <img :src="prod.src" /> Commented Jun 2, 2020 at 13:00
  • if the images are accessible through web then it's simply what @Ifaruki stated Commented Jun 2, 2020 at 13:05
  • @Ifaruki it works! thanks. Commented Jun 2, 2020 at 13:05

1 Answer 1

1

You bind it wrong.

Change this line:

<img :src="require(`${prod.src}`)" />

To this:

<img :src="prod.src" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.