Vue lazyload懒加载使用
当我们项目使用到大量的图片时候,为了解决不必要的资源浪费,一般会选择一个懒加载。下面就说一下vue-lazyload插件的使用第一步。下载 npm install vue-lazyload 第二步。在main.js中启用此插件 import VueLazyload from 'vue-lazyload'Vue.use(VueLazyload,{loading:'../static/img/...
·
当我们项目使用到大量的图片时候,为了解决不必要的资源浪费,一般会选择一个懒加载。下面就说一下vue-lazyload插件的使用
第一步。下载 npm install vue-lazyload
第二步。在main.js中启用此插件
import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload,{
loading:'../static/img/load.png'
});
第三步。在实例中使用
<img v-lazy="item.imgurl" >
其中 用v-lazy 代替:src 这样 懒加载就完成了。
下面介绍一下文档
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
更多推荐
已为社区贡献28条内容
所有评论(0)