Vue.js v2.x +的惰性加载和视图内检测插件。
# NPM
$ npm install vue-l-lazyload --save
一种简单的方法:
import { VueLLazyload } from 'vue-l-lazyload';
// 对于具有树抖动的较小的生产代码,我建议您导入
// 导入 { VueLLazyloadLocal: VueLLazyload } 到'vue-l-lazyload/src';
Vue.use(VueLLazyload, {
events: 'scroll'
});
// 根目录$lazy“Vue.$lazy”将在安装后可用
<img lazy="xxx.png">
一种更可配置的方式:
import { VueLLazyload } from 'vue-l-lazyload';
Vue.use(VueLLazyload, config);
<lazy-ref ref="lazyRef" opts="config">
<img lazy="{src:xxx.png, ref:'lazyRef'}">
</lazy-ref>