vue框架中实现图片懒加载 详细地址:https://github.com/hilongjw/vue-lazyload
步骤:
【vue|vue中的图片懒加载-vueLazyLoad】1. 安装
npm install vue-lazyload--save
2. 在main.js文件中导入引用
import vueLazyLoad from 'vue-lazyload';
3. 安装插件
//朴素版
Vue.use(vueLazyLoad);
//丰富版
Vue.use(vueLazyLoad,{
preLoad: 1.3,
error: require('./assets/img/common/error.png'),
loading: require('./assets/img/common/placeholder.png'),
attempt: 1,
// the default is ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend']
listenEvents: [ 'scroll' ]
});
4. 需要懒加载的图片修改:src为v-lazy
>
export default {
name: "GoodsListItem"
}
推荐阅读
- JavaScript|vue 基于axios封装request接口请求——request.js文件
- 前端|web前端dya07--ES6高级语法的转化&render&vue与webpack&export
- 前端开发|Vue2.x API 学习
- vue|Vue面试常用详细总结
- vue|电商后台管理系统(vue+python|node.js)
- 腾讯TEG实习|腾讯实习——Vue解决跨域请求
- Vue|vue-router 详解
- vue|vue3替代vuex的框架piniajs实例教程
- Vue|Vue3.0的插槽是如何实现的()
- 前端|面试官(谈谈Vue和React的区别())