UNPKG

vuux

Version:

Vue3 Nuxt3 Nuxt4 组件库

6 lines (5 loc) 711 B
"use strict";const n=`data:image/svg+xml;utf8,${encodeURIComponent(` <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"> <rect width="100%" height="100%" fill="rgba(245, 247, 250, 1)"/> </svg> `)}`,s=new WeakMap,v=typeof window<"u"&&typeof IntersectionObserver<"u",d={mounted(e,t){if(!v){e.src=t.value;return}e.src=n;const c=()=>{const o=new Image;o.onload=()=>{e.src=t.value},o.onerror=()=>{e.src=n},o.src=t.value},r=new IntersectionObserver((o,i)=>{for(const a of o)if(a.isIntersecting){c(),i.unobserve(e);break}},{root:null,rootMargin:"0px",threshold:.1});r.observe(e),s.set(e,r)},unmounted(e){const t=s.get(e);t&&(t.unobserve(e),t.disconnect(),s.delete(e))}};module.exports=d;