current position:Home>Vue lazy loading Vue lazload

Vue lazy loading Vue lazload

2022-01-27 04:59:42 Mily_ k

1. download

npm i vue-lazyload -S

2. Import mount

import Vue from 'vue'
import App from './App.vue'
import VueLazyload from 'vue-lazyload'
//  perhaps 
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: 'dist/error.png',
  loading: 'dist/loading.gif',
  attempt: 1
new Vue({
  el: 'body',
  components: {

3. stay vue Use in

  <li v-for="img in list">
    <img v-lazy="img.src" >

4. stay html Use in

<div v-lazy-container="{ selector: 'img' }">
  <img data-src="//">
  <img data-src="//">
  <img data-src="//">  

copyright notice
author[Mily_ k],Please bring the original link to reprint, thank you.

Random recommended