vue-lazyload
vue-lazyload copied to clipboard
inline @load @loading @error events
How can we use add these event listener per inline item?
for example
<img v-for="(item, index) in items" v-lazy="https://example.com/photo.jpg" @loading="onLoading(index)"/>
We specifically want to pass the index to the callback.
it should be implemented in the lazyImage component, but not yet
@hilongjw is there any documentation about the lazy-image
component? I can't seem to find it.
Okay, I found out that it wasn't documented and we need to enable the component by passing lazyImage: true
to the options
.
It's working, but is there any reason why it isn't documented?
@julian-ca because the current implementation is relatively simple
so where is a example to do that?
Any ideas on this, I want to also do this? I'd like to have a error listener in my component which then does something
So it's not possible to use @error inline on an image tag?
<img v-lazy="https://example.com/photo.jpg" @error="onError()" />
Currently error never fires because it's the default img
error handler and vue-lazyload always has a legit blank image inside of src. So I need the vue-lazyload error to bubble up when it fails to load the real image.
@alexcroox you can refer to my code.
I've modified the vue-lazyload's lazy-image
component a little bit.
https://github.com/WisdomSky/wisdomsky.github.io/tree/develop/src/vue-lazyload
and then installed the plug-in. Make sure that lazyImage
flag is passed in the config.
https://github.com/WisdomSky/wisdomsky.github.io/blob/develop/src/main.js#L16
Then use it. You can see in my code that I'm using @loading
.
https://github.com/WisdomSky/wisdomsky.github.io/blob/develop/src/views/Photography.vue#L27
but @error
is available too.
https://github.com/WisdomSky/wisdomsky.github.io/blob/develop/src/vue-lazyload/lazy-image.js#L94
I've added three handy events. @loading
, @loaded
and @error
.
@hilongjw is the implementation from @WisdomSky PR worthy? It would be nice to get the events.
@WisdomSky thanks for the work, I'll use your fork for now.