hilongjw / vue-lazyload

A Vue.js plugin for lazyload your Image or Component in your application.
http://hilongjw.github.io/vue-lazyload/
MIT License
7.99k stars 865 forks source link

Is there a way to prevent console logging 404 error? #497

Open summerset-zz opened 2 years ago

summerset-zz commented 2 years ago

I've already tried this:

    app.use(VueLazyload, {
        preload: 1,
        error: LAZY_ERROR,
        loading: LAZY_LOADING,
        attempt: 3,
        dispatchEvent: true,
        adapter: {
            error(listener, Init) {
                console.log(listener);
            },
        },
    });

but in arguments of error adapter I found no way to stop it.

and I also tried to add @error="errorHandler" to the <img> element. I can catch the event, but e.preventDefault() has no use:

const errorHandler = (e: CustomEvent<any>) => {
    e.preventDefault();
    console.log(e)
}
// the type of 'e' is 'ReactiveListener'

currently using vue 3.2.37, vue-lazyload 3.0.0-rc.2