vue-lazyload icon indicating copy to clipboard operation
vue-lazyload copied to clipboard

Backround image null loading

Open arkhamvm opened this issue 5 years ago • 1 comments

Hi. Here is my template:

<div	v-lazy:background-image="(isSpecial ? image.url : null)">
    <div>title</div>
    <img v-lazy="(false === isSpecial ? image.url : null)">
</div>

And config:

Vue.use(VueLazyload, {
	preLoad: 1.3,
	error:   '/images/lazy-error.png',
	loading: '/images/lazy-loading.png',
	attempt: 1,
	filter:  {
		webp(listener, options) {
			if (!options.supportWebp || !listener.src || /\.webp$/.test(listener.src)) {
				return;
			}

			listener.src += '.webp';
		},
	},
});

When isSpecial === false I expected no background-image in root div, but get lazy-error.png. How i can solve it?

arkhamvm avatar Mar 02 '20 09:03 arkhamvm

const loadImageAsync = (item, resolve, reject) => {
  let image = new Image()
  if (!item || !item.src) {
    const err = new Error('image src is required')
    return reject(err)
  }
}

It would be nice to have some empty value (like 'none') that doesn't trigger error, and don't append image. It also would be nice for loading/error images.

arkhamvm avatar Mar 03 '20 05:03 arkhamvm