/*! For license information please see 8409.c156202a.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["8409"],{70561:function(s,a,n){"use strict";n.r(a);var t=n("80681");let e=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
When the page needs to load a large amount of content, delay loading the content outside the visible area of the page to make the page load smoother.
\nRegister component globally via app.use, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { Lazyload } from 'vant';\n\nconst app = createApp();\napp.use(Lazyload);\n\n// with options\napp.use(Lazyload, {\n lazyComponent: true,\n});\n\n<img v-for="img in imageList" v-lazy="img" />\n\nexport default {\n setup() {\n return {\n imageList: [\n 'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',\n 'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',\n ],\n };\n },\n};\n\nUse v-lazy:background-image to set background url, and declare the height of the container.
<div v-for="img in imageList" v-lazy:background-image="img" />\n\n// set `lazyComponent` option\napp.use(Lazyload, {\n lazyComponent: true,\n});\n\n<lazy-component>\n <img v-for="img in imageList" v-lazy="img" />\n</lazy-component>\n\n| Attribute | \nDescription | \nType | \nDefault | \n
|---|---|---|---|
| loading | \nSrc of the image while loading | \nstring | \n- | \n
| error | \nSrc of the image upon load fail | \nstring | \n- | \n
| preLoad | \nProportion of pre-loading height | \nnumber | \n- | \n
| attempt | \nAttempts count | \nnumber | \n3 | \n
| listenEvents | \nEvents that you want vue listen for | \nstring[] | \nscroll... | \n
| adapter | \nDynamically modify the attribute of element | \nobject | \n- | \n
| filter | \nThe image\'s listener filter | \nobject | \n- | \n
| lazyComponent | \nLazyload component | \nboolean | \nfalse | \n
\n\nSee more: vue-lazyload
\n