vue3图片懒加载vue3-lazy的使用

github地址:https://github.com/ustbhuangyi/vue3-lazy

main.js:

import App from './App.vue'
import lazyPlugin from 'vue3-lazy'

createApp(App)
      .use(lazyPlugin, {
    loading: require('@/assets/images/default.png'), // 图片加载时默认图片
    error: require('@/assets/images/error.png')// 图片加载失败时默认图片
  })
  .mount('#app')

 template

<ul>
  <li v-for="img in list">
    <img v-lazy="img.src" >
  </li>
</ul>

猜你喜欢

转载自blog.csdn.net/qq_40895460/article/details/120621484