网站地图    收藏   

主页 > 前端 > vue教程 >

最详细的vue懒加载v-lazyload教程

来源:未知    时间:2021-12-21 13:38 作者:小飞侠 阅读:

[导读] Vue-Lazyload Vue module for lazyloading images in your applications. Some of goals of this project worth noting include: Be lightweight, powerful and easy to use Work on any image type Add loading class while image is loading Supports both...

Vue-Lazyload

Build Status
npm version
npm downloads
npm license
PRs Welcome
CDNJS version

Vue module for lazyloading images in your applications. Some of goals of this project worth noting include:

  • Be lightweight, powerful and easy to use

  • Work on any image type

  • Add loading class while image is loading

  • Supports both of Vue 1.0 and Vue 2.0


Table of Contents


Demo

Demo


Requirements


Installation


npm


$ npm i vue-lazyload -S


CDN

CDN: https://unpkg.com/vue-lazyload/vue-lazyload.js


<script src="https://unpkg.com/vue-lazyload/vue-lazyload.js"></script><script>
  Vue.use(VueLazyload)
  ...</script>


Usage

main.js:


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

template:


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

use v-lazy-container work with raw HTML

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论