Answers for "vue image dynamic src local image"

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

Browse Popular Code Answers by Language