vue-lazyload vue image lazy loading plugin usage record

first download

 npm i vue-lazyload --save-dev
然后在main.js 入口文件中配置引入
import VueLazyLoad from 'vue-lazyload'

然后配置默认加载图片

Vue.use(VueLazyLoad, {
  loading: require('./images/default.png') // 加载的默认图片路径
})

Finally use v-lazy instead of :src in the .vue file to bind the image Example:

<img width="57" height="57" v-lazy="food.icon" alt="">

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521217&siteId=291194637