Lazy Loading Images with Vue in Laravel

I'm hoping maybe someone can help me with this, I have a Vue component that displays a lot of images (similiar to a gallery), so I would like to lazy load them. I've been trying to use this - http://appelsiini.net/projects/lazyload/ - but I have run into an issue with getting it work in my Vue component.

I have this img code block:

<img v-if="vehicle.photo_path != null" :data-original="'/storage/vehicles/' + vehicle.photo_path" class="lazy" height="180" width="150"/>

And I thought that would work, but when I load the page all I am getting is a white square with a grey border around it where the image should be - and if I change data-original to src then the image will display correctly.

I know I have implemented the Lazy Loading js file correctly because I can call it elsewhere on my site with success - such as in my blade views, just not in my Vue component it seems.

If anyone has any ideas on how I could fix this then it would be much appreciated because I'm really stuck on trying to figure it out.

Posted Aug 22, 2017, 4:56 AM UTC

10

No comments yet

Nobody commented on this post, or the comments weren't captured.