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

  1. Be lightweight, powerful and easy to use
  2. Work on any image type
  3. Add loading class while image is loading
  4. Supports both of Vue 1.0 and Vue 2.0

github地址: https://github.com/hilongjw/vue-lazyload

  1. 下载依赖

    npm install vue-lazyload --save
  2. 引入

    import Vue from 'vue'
    import App from '@/App'
    import VueLazyload from 'vue-lazyload'
  3. 配置

    Vue.use(VueLazyload, {
    error: 'dist/error.png', // 这个是请求失败后显示的图片
    loading: 'dist/loading.gif', // 这个是加载的loading过渡效果
    try: 2 // 这个是加载图片数量
    })
  4. 组件使用

    <template>
    <div class="lazyLoad">
    <ul id="container">
    <li v-for="img in arr">
    <img v-lazy="img.thumbnail_pic_s">
    </li>
    </ul>
    </div>
    </template> <script>
    export default({
    name:"lazyLoad",
    data(){
    return{
    arr:[]
    }
    },
    mounted:function(){
    this.$http.get('/api/data').then(res=>{
    this.arr=res.data.data;
    console.log(this.data)
    })
    },
    })
    </script> <style scoped>
    li{
    list-style: none
    }
    </style>
  5. 如果需求中是, 不同的组件中默认的loading图不同. 可如下配置

    v-lazy:background-image="{src: item.src, error: 'http://domain.com/error.png', loading: 'http://domain.com/loading-spin.svg'}"

最新文章

  1. php 去掉字符串的最后一个字符
  2. LVM逻辑卷管理
  3. codeforces 711A A. Bus to Udayland(水题)
  4. NEFU 1142 表哥的面包
  5. java mvc控制器基本传值方式
  6. nginx linux 下开机自动启动
  7. Spark机器学习 Day1 机器学习概述
  8. 5个最优秀的Java和C#代码转换工具
  9. spring beans源码解读
  10. Mac苹果电脑加密视频播放器使用教程
  11. CSS 伪元素
  12. 怎样在android实现uc和墨迹天气那样的左右拖动效果
  13. 脱O把妹,记录这一周来迁移至MySQL的一些心得
  14. Android系统--输入系统(十五)实战_使用GlobalKey一键启动程序
  15. 关于mule中使用jdbc时报No Suitable Driver found错误的问题
  16. java中,用json格式转换遇到问题
  17. vue 格式化银行卡(信用卡)每4位一个符号隔断
  18. .net core 2.x - 缓存的四种方式
  19. sybase解决死锁
  20. cdh启动datanode报错

热门文章

  1. DOS下如何打开程序
  2. android-基础编程之开篇
  3. stm32的gpio函数介绍
  4. 配置SecureCRT密钥连接Linux
  5. SSM_CRUD新手练习(5)测试mapper
  6. 《mysql必知必会》学习_第11章_20180801_欢
  7. js加减运算·传参
  8. hdu 1226 超级密码
  9. [SDOI2011]消耗战(虚树+树形动规)
  10. 同一域名基于源ip地址分配给不同ip的dns配置--bind9.8.2