[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-10053":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":23,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":30,"discoverSource":31},10053,"vue-lazyload","hilongjw\u002Fvue-lazyload","hilongjw","A Vue.js plugin for lazyload your Image or Component in your application.","http:\u002F\u002Fhilongjw.github.io\u002Fvue-lazyload\u002F",null,"JavaScript",8006,864,89,188,0,2,1,66.01,"MIT License",false,"master",true,[25,26,5],"lazyload","vue","2026-06-12 04:00:48","# Vue-Lazyload\n\n[![Build Status](https:\u002F\u002Fimg.shields.io\u002Fcircleci\u002Fproject\u002Fhilongjw\u002Fvue-lazyload\u002Fmaster.svg?style=flat-square)](https:\u002F\u002Fcircleci.com\u002Fgh\u002Fhilongjw\u002Fvue-lazyload)\n[![npm version](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fv\u002Fvue-lazyload.svg?style=flat-square)](http:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fvue-lazyload)\n[![npm downloads](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdm\u002Fvue-lazyload.svg?style=flat-square)](http:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fvue-lazyload)\n[![npm license](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fl\u002Fvue-lazyload.svg?style=flat-square)](http:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fvue-lazyload)\n[![PRs Welcome](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPRs-welcome-brightgreen.svg?style=flat-square)](http:\u002F\u002Fmakeapullrequest.com)\n[![CDNJS version](https:\u002F\u002Fimg.shields.io\u002Fcdnjs\u002Fv\u002Fvue-lazyload.svg)](https:\u002F\u002Fcdnjs.com\u002Flibraries\u002Fvue-lazyload)\n\nVue module for lazyloading images in your applications. Some of goals of this project worth noting include:\n\n* Be lightweight, powerful and easy to use\n* Work on any image type\n* Add loading class while image is loading\n* Supports both of Vue 1.0 and Vue 2.0\n\n# For Vue 3\nPlease use vue-lazyload@3.x, see [here](https:\u002F\u002Fgithub.com\u002Fhilongjw\u002Fvue-lazyload\u002Ftree\u002Fnext)\n\n# Table of Contents\n\n* [___Demo___](#demo)\n* [___Requirements___](#requirements)\n* [___Installation___](#installation)\n* [___Usage___](#usage)\n * [___Constructor Options___](#constructor-options)\n * [___Implementation___](#implementation)\n    * [___Basic___](#basic)\n    * [___Css state___](#css-state)\n* [___Methods___](#methods)\n  * [__Event hook__](#event-hook)\n  * [__LazyLoadHandler__](#lazyloadhandler)\n  * [__Performance__](#performance)\n* [___Authors && Contributors___](#authors-&&-Contributors)\n* [___License___](#license)\n\n\n# Demo\n\n[___Demo___](http:\u002F\u002Fhilongjw.github.io\u002Fvue-lazyload\u002F)\n\n# Requirements\n\n- [Vue.js](https:\u002F\u002Fgithub.com\u002Fvuejs\u002Fvue) `1.x` or `2.x`\n\n\n# Installation\n\n## npm\n\n```bash\n\n$ npm i vue-lazyload -S\n\n```\n\n## yarn\n\n```bash\n\n$ yarn add vue-lazyload\n\n```\n\n## CDN\n\nCDN: [https:\u002F\u002Funpkg.com\u002Fvue-lazyload\u002Fvue-lazyload.js](https:\u002F\u002Funpkg.com\u002Fvue-lazyload\u002Fvue-lazyload.js)\n\n```html\n\u003Cscript src=\"https:\u002F\u002Funpkg.com\u002Fvue-lazyload\u002Fvue-lazyload.js\">\u003C\u002Fscript>\n\u003Cscript>\n  Vue.use(VueLazyload)\n  ...\n\u003C\u002Fscript>\n\n```\n\n# Usage\n\nmain.js:\n\n```javascript\n\nimport Vue from 'vue'\nimport App from '.\u002FApp.vue'\nimport VueLazyload from 'vue-lazyload'\n\nVue.use(VueLazyload)\n\n\u002F\u002F or with options\nconst loadimage = require('.\u002Fassets\u002Floading.gif')\nconst errorimage = require('.\u002Fassets\u002Ferror.gif')\n\nVue.use(VueLazyload, {\n  preLoad: 1.3,\n  error: errorimage,\n  loading: loadimage,\n  attempt: 1\n})\n\nnew Vue({\n  el: 'body',\n  components: {\n    App\n  }\n})\n```\n\ntemplate:\n\n```html\n\u003Cul>\n  \u003Cli v-for=\"img in list\">\n    \u003Cimg v-lazy=\"img.src\" >\n  \u003C\u002Fli>\n\u003C\u002Ful>\n```\n\nuse `v-lazy-container` work with raw HTML\n\n```html\n\u003Cdiv v-lazy-container=\"{ selector: 'img' }\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg1.jpg\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg2.jpg\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg3.jpg\">  \n\u003C\u002Fdiv>\n```\n\ncustom `error` and `loading` placeholder image\n\n```html\n\u003Cdiv v-lazy-container=\"{ selector: 'img', error: 'xxx.jpg', loading: 'xxx.jpg' }\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg1.jpg\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg2.jpg\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg3.jpg\">  \n\u003C\u002Fdiv>\n```\n\n```html\n\u003Cdiv v-lazy-container=\"{ selector: 'img' }\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg1.jpg\" data-error=\"xxx.jpg\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg2.jpg\" data-loading=\"xxx.jpg\">\n  \u003Cimg data-src=\"\u002F\u002Fdomain.com\u002Fimg3.jpg\">  \n\u003C\u002Fdiv>\n```\n\n## Constructor Options\n\n|key|description|default|options|\n|:---|---|---|---|\n| `preLoad`|proportion of pre-loading height|`1.3`|`Number`|\n|`error`|src of the image upon load fail|`'data-src'`|`String`\n|`loading`|src of the image while loading|`'data-src'`|`String`|\n|`attempt`|attempts count|`3`|`Number`|\n|`listenEvents`|events that you want vue listen for|`['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove']`| [Desired Listen Events](#desired-listen-events) |\n|`adapter`| dynamically modify the attribute of element |`{ }`| [Element Adapter](#element-adapter) |\n|`filter`| the image's listener filter |`{ }`| [Image listener filter](#image-listener-filter) |\n|`lazyComponent`| lazyload component | `false` | [Lazy Component](#lazy-component)\n| `dispatchEvent`|trigger the dom event|`false`|`Boolean`|\n| `throttleWait`|throttle wait|`200`|`Number`|\n| `observer`|use IntersectionObserver|`false`|`Boolean`|\n| `observerOptions`|IntersectionObserver options|{ rootMargin: '0px', threshold: 0.1 }|[IntersectionObserver](#intersectionobserver)|\n| `silent`|do not print debug info|`true`|`Boolean`|\n\n### Desired Listen Events\n\nYou can configure which events you want vue-lazyload by passing in an array\nof listener names.\n\n```javascript\nVue.use(VueLazyload, {\n  preLoad: 1.3,\n  error: 'dist\u002Ferror.png',\n  loading: 'dist\u002Floading.gif',\n  attempt: 1,\n  \u002F\u002F the default is ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend']\n  listenEvents: [ 'scroll' ]\n})\n```\n\nThis is useful if you are having trouble with this plugin resetting itself to loading\nwhen you have certain animations and transitions taking place\n\n\n### Image listener filter\n\ndynamically modify the src of image\n\n```javascript\nVue.use(vueLazy, {\n    filter: {\n      progressive (listener, options) {\n          const isCDN = \u002Fqiniudn.com\u002F\n          if (isCDN.test(listener.src)) {\n              listener.el.setAttribute('lazy-progressive', 'true')\n              listener.loading = listener.src + '?imageView2\u002F1\u002Fw\u002F10\u002Fh\u002F10'\n          }\n      },\n      webp (listener, options) {\n          if (!options.supportWebp) return\n          const isCDN = \u002Fqiniudn.com\u002F\n          if (isCDN.test(listener.src)) {\n              listener.src += '?imageView2\u002F2\u002Fformat\u002Fwebp'\n          }\n      }\n    }\n})\n```\n\n\n### Element Adapter\n\n```javascript\nVue.use(vueLazy, {\n    adapter: {\n        loaded ({ bindType, el, naturalHeight, naturalWidth, $parent, src, loading, error, Init }) {\n            \u002F\u002F do something here\n            \u002F\u002F example for call LoadedHandler\n            LoadedHandler(el)\n        },\n        loading (listender, Init) {\n            console.log('loading')\n        },\n        error (listender, Init) {\n            console.log('error')\n        }\n    }\n})\n```\n\n### IntersectionObserver\n\nuse [Intersection Observer](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FAPI\u002FIntersection_Observer_API) to to improve performance of a large number of nodes.\n\n```javascript\nVue.use(vueLazy, {\n  \u002F\u002F set observer to true\n  observer: true,\n\n  \u002F\u002F optional\n  observerOptions: {\n    rootMargin: '0px',\n    threshold: 0.1\n  }\n})\n```\n\n\n### Lazy Component\n```javascript\nVue.use(VueLazyload, {\n  lazyComponent: true\n});\n```\n\n```html\n\u003Clazy-component @show=\"handler\">\n  \u003Cimg class=\"mini-cover\" :src=\"img.src\" width=\"100%\" height=\"400\">\n\u003C\u002Flazy-component>\n\n\u003Cscript>\n  {\n    ...\n    methods: {\n      handler (component) {\n        console.log('this component is showing')\n      }\n    }\n\n  }\n\u003C\u002Fscript>\n```\nUse in list\n```html\n\u003Clazy-component v-for=\"(item, index) in list\" :key=\"item.src\" >\n  \u003Cimg class=\"mini-cover\" :src=\"item.src\" width=\"100%\" height=\"400\">\n\u003C\u002Flazy-component>\n```\n\n\n## Implementation\n\n### Basic\n\nvue-lazyload will set this img element's `src` with `imgUrl` string\n\n```html\n\u003Cscript>\nexport default {\n  data () {\n    return {\n      imgObj: {\n        src: 'http:\u002F\u002Fxx.com\u002Flogo.png',\n        error: 'http:\u002F\u002Fxx.com\u002Ferror.png',\n        loading: 'http:\u002F\u002Fxx.com\u002Floading-spin.svg'\n      },\n      imgUrl: 'http:\u002F\u002Fxx.com\u002Flogo.png' \u002F\u002F String\n    }\n  }\n}\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Cdiv ref=\"container\">\n     \u003Cimg v-lazy=\"imgUrl\"\u002F>\n     \u003Cdiv v-lazy:background-image=\"imgUrl\">\u003C\u002Fdiv>\n\n     \u003C!-- with customer error and loading -->\n     \u003Cimg v-lazy=\"imgObj\"\u002F>\n     \u003Cdiv v-lazy:background-image=\"imgObj\">\u003C\u002Fdiv>\n\n     \u003C!-- Customer scrollable element -->\n     \u003Cimg v-lazy.container =\"imgUrl\"\u002F>\n     \u003Cdiv v-lazy:background-image.container=\"img\">\u003C\u002Fdiv>\n\n    \u003C!-- srcset -->\n    \u003Cimg v-lazy=\"'img.400px.jpg'\" data-srcset=\"img.400px.jpg 400w, img.800px.jpg 800w, img.1200px.jpg 1200w\">\n    \u003Cimg v-lazy=\"imgUrl\" :data-srcset=\"imgUrl' + '?size=400 400w, ' + imgUrl + ' ?size=800 800w, ' + imgUrl +'\u002F1200.jpg 1200w'\" \u002F>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n```\n\n### CSS state\n\nThere are three states while img loading\n\n`loading`  `loaded`  `error`\n\n```html\n\u003Cimg src=\"imgUrl\" lazy=\"loading\">\n\u003Cimg src=\"imgUrl\" lazy=\"loaded\">\n\u003Cimg src=\"imgUrl\" lazy=\"error\">\n```\n\n```html\n\u003Cstyle>\n  img[lazy=loading] {\n    \u002F*your style here*\u002F\n  }\n  img[lazy=error] {\n    \u002F*your style here*\u002F\n  }\n  img[lazy=loaded] {\n    \u002F*your style here*\u002F\n  }\n  \u002F*\n  or background-image\n  *\u002F\n  .yourclass[lazy=loading] {\n    \u002F*your style here*\u002F\n  }\n  .yourclass[lazy=error] {\n    \u002F*your style here*\u002F\n  }\n  .yourclass[lazy=loaded] {\n    \u002F*your style here*\u002F\n  }\n\u003C\u002Fstyle>\n```\n\n## Methods\n\n### Event Hook\n\n`vm.$Lazyload.$on(event, callback)`\n`vm.$Lazyload.$off(event, callback)`\n`vm.$Lazyload.$once(event, callback)`\n\n- `$on` Listen for a custom events `loading`, `loaded`, `error`\n- `$once` Listen for a custom event, but only once. The listener will be removed once it triggers for the first time.\n- `$off` Remove event listener(s).\n\n#### `vm.$Lazyload.$on`\n\n#### Arguments:\n\n * `{string} event`\n * `{Function} callback`\n\n#### Example\n\n```javascript\nvm.$Lazyload.$on('loaded', function ({ bindType, el, naturalHeight, naturalWidth, $parent, src, loading, error }, formCache) {\n  console.log(el, src)\n})\n```\n\n#### `vm.$Lazyload.$once`\n\n#### Arguments:\n\n * `{string} event`\n * `{Function} callback`\n\n#### Example\n\n```javascript\nvm.$Lazyload.$once('loaded', function ({ el, src }) {\n  console.log(el, src)\n})\n```\n\n#### `vm.$Lazyload.$off`\n\nIf only the event is provided, remove all listeners for that event\n\n#### Arguments:\n\n * `{string} event`\n * `{Function} callback`\n\n#### Example\n\n```javascript\nfunction handler ({ el, src }, formCache) {\n  console.log(el, src)\n}\nvm.$Lazyload.$on('loaded', handler)\nvm.$Lazyload.$off('loaded', handler)\nvm.$Lazyload.$off('loaded')\n```\n\n### LazyLoadHandler\n\n`vm.$Lazyload.lazyLoadHandler`\n\nManually trigger lazy loading position calculation\n\n#### Example\n\n```javascript\n\nthis.$Lazyload.lazyLoadHandler()\n\n```\n\n### Performance\n\n```javascript\nthis.$Lazyload.$on('loaded', function (listener) {\n  console.table(this.$Lazyload.performance())\n})\n```\n\n![performance-demo](http:\u002F\u002Fww1.sinaimg.cn\u002Flarge\u002F69402bf8gw1fbo62ocvlaj213k09w78w.jpg)\n\n### Dynamic switching pictures\n\n```vue\n \u003Cimg v-lazy=\"lazyImg\" :key=\"lazyImg.src\">\n```\n\n\n# Authors && Contributors\n\n- [hilongjw](https:\u002F\u002Fgithub.com\u002Fhilongjw)\n- [imcvampire](https:\u002F\u002Fgithub.com\u002Fimcvampire)\n- [darrynten](https:\u002F\u002Fgithub.com\u002Fdarrynten)\n- [biluochun](https:\u002F\u002Fgithub.com\u002Fbiluochun)\n- [whwnow](https:\u002F\u002Fgithub.com\u002Fwhwnow)\n- [Leopoldthecoder](https:\u002F\u002Fgithub.com\u002FLeopoldthecoder)\n- [michalbcz](https:\u002F\u002Fgithub.com\u002Fmichalbcz)\n- [blue0728](https:\u002F\u002Fgithub.com\u002Fblue0728)\n- [JounQin](https:\u002F\u002Fgithub.com\u002FJounQin)\n- [llissery](https:\u002F\u002Fgithub.com\u002Fllissery)\n- [mega667](https:\u002F\u002Fgithub.com\u002Fmega667)\n- [RobinCK](https:\u002F\u002Fgithub.com\u002FRobinCK)\n- [GallenHu](https:\u002F\u002Fgithub.com\u002FGallenHu)\n\n# License\n\n[The MIT License](http:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n","Vue-Lazyload 是一个用于 Vue.js 应用中的图片或组件懒加载插件。其核心功能包括支持所有类型的图片延迟加载，以及在图片加载过程中添加加载类以提供更好的用户体验。该插件轻量级、易于使用且强大，同时兼容 Vue 1.0 和 Vue 2.0 版本（对于 Vue 3 用户，请使用 vue-lazyload@3.x）。通过设置预加载比例、错误和加载占位符等选项，开发者可以灵活地控制加载行为。适用于需要优化页面性能、减少初始加载时间的场景，特别是当页面包含大量图片时。","2026-06-11 03:26:18","top_topic"]