Answers for "vue img src dynamic"

0

vue dynamic image src

<template>
   <div v-for="pic in pics">
      <img :src="getImgUrl(pic)" v-bind:alt="pic">
   </div>
</template>

<script>
  getImgUrl(pet) {
    var images = require.context('../assets/', false, /\.png$/)
    return images('./' + pet + ".png")
  }
</script>
Posted by: Guest on October-09-2021
0

vue image src

<img v-bind:src="'/media/avatars/' + joke.avatar" />
Posted by: Guest on April-27-2021
1

add images in data object vuejs

<template>
  <div id="app">
    <img :src="image" />
  </div>
</template>

<script>
import image from "./assets/logo.png"


export default {
    data: function () {
        return {
            image: image
        }
    }
}
</script>
Posted by: Guest on July-21-2020

Browse Popular Code Answers by Language