Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install and use lazy loading of v lazy pictures

Shulou Source: shulou.com Published: 2022-06-03 06:21:53 10月04日 Update

How to install v lazy pictures lazy loading, I believe many inexperienced people are helpless about this, this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.

vue is based on vue-lazyload image lazy loading, delayed loading vue-lazyload plug-in effect is the default does not load images.

vlazy pictures lazy loading plug-ins

npminstallvue-lazyload--save-dev

Introduced and used in the entry file main.js

importVueLazyloadfrom'vue-lazyload'

Vue.use(VueLazyload,{

loading:require ('img/loading.png '),//Loading images, must have, otherwise it will be loaded repeatedly

error:require ('img/error.png ')//load failed image

});

Change the image display mode to vlazy image lazy loading

img:

//Change the src attribute to v-lazy,:key is to prevent the image from updating when the page is refreshed or the image is changed

Background image:

v-html, as in a rich text string fetched from the background Picture: (replace src with data-src)

After reading the above content, do you know how to install v lazy pictures? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Picture content plug-in method more problem helpless for this entry reason background character string this attribute skill effect file text way Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Xiaomi Shulou Technology Apple Microsoft