0

I have an array of images. So, what I want to do is load images if only it exists. I tried several methods but that didn't work at all.

new Vue({
  el: '#app',
  data: {
    images: [
      '200x200',
      '200x200',
      '200x200',
      '200x200',
      '200x200',
      '200x200',
      '200x200',
      '200x200',
      '200x200',
      'noxno', //invalid image
      'noxno', //invalid image
      'noxno', //invalid image
      'noxno' //invalid image
    ]
  }
})
<div id="app">
  <img v-for="image in images" :src="'https://via.placeholder.com/' + image" alt="">
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>

JSFiddle: http://jsfiddle.net/ya2r34zj/3/

Axel
  • 4,365
  • 11
  • 63
  • 122

0 Answers0