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'
 
Vue.use(VueLazyload)
 
//  perhaps 
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: 'dist/error.png',
  loading: 'dist/loading.gif',
  attempt: 1
})
 
new Vue({
  el: 'body',
  components: {
    App
  }
})

3. stay vue Use in

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

4. stay html Use in

<div v-lazy-container="{ selector: 'img' }">
  <img data-src="//domain.com/img1.jpg">
  <img data-src="//domain.com/img2.jpg">
  <img data-src="//domain.com/img3.jpg">  
</div>

copyright notice
author[Mily_ k],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270459408508.html

Random recommended