欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue-lazyload圖片延遲加載插件的實(shí)例講解

 更新時(shí)間:2018年02月09日 09:24:27   作者:longzhoufeng  
下面小編就為大家分享一篇vue-lazyload圖片延遲加載插件的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

1、首先在npm上下載vue-lazyload的引用包

npm install vue-lazyload --save-dev

2、然后我們?cè)趍ain.js里面import這個(gè)包,當(dāng)然,單單這一個(gè)包是不夠的,還得其他的文件

import Vue from 'vue';
import App from './App.vue'
import router from './router';
import VueLazyload from "vue-lazyload"

3、然后我們配置vue-lazyload

Vue.use(VueLazyload, {
error: 'static/error.png',//這個(gè)是請(qǐng)求失敗后顯示的圖片
loading: 'static/loading.gif',//這個(gè)是加載的loading過渡效果
try: 2 // 這個(gè)是加載圖片數(shù)量
})

4、具體配置api可以看下圖

html

<template>
 <div>
  <ul id="container">
   <li v-for="img in list">
    <img v-lazy="img">
   </li>
  </ul>
 </div>
</template>

JS

<script>
 export default {
 data () {
  return {
    list: [
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
    'http://st2.depositphotos.com/thumbs/2627021/image/9638/96385166/api_thumb_450.jpg!thumb',
   ]
  }
 }
 }
</script>

css

<style>
//圖片加載中...
img[lazy=loading] {
 /*width: 100px;*/
 background-position:center center!important;
 background: url("../../../static/images/loading.gif");
 background-size:100px 100px;
 background-repeat:no-repeat;
 -webkit-background-size: cover;
 -moz-background-size: cover;
 -o-background-size: cover;
 background-size: cover;
}
img[lazy=error] {
 /*width: 100px;*/
 background-position:center center!important;
 background: url("../../../static/images/error.png");
 background-size:100px 100px;
 background-repeat:no-repeat;
 -webkit-background-size: cover;
 -moz-background-size: cover;
 -o-background-size: cover;
 background-size: cover;
}
img[lazy=loaded] {
 /*width: 100px;*/
 background-position:center center!important;
 -webkit-background-size: cover;
 -moz-background-size: cover;
 -o-background-size: cover;
 background-size: cover;
 background-color: green;
}
/*
 or background-image
 */
 .yourclass[lazy=loading] {
 /*your style here*/
 }
 .yourclass[lazy=error] {
 /*your style here*/
 }
 .yourclass[lazy=loaded] {
 /*your style here*/
 }
</style>

以上這篇vue-lazyload圖片延遲加載插件的實(shí)例講解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • @vue/cli4.x版本的vue.config.js常用配置方式

    @vue/cli4.x版本的vue.config.js常用配置方式

    這篇文章主要介紹了@vue/cli4.x版本的vue.config.js常用配置方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • Vue路由守衛(wèi)之路由獨(dú)享守衛(wèi)

    Vue路由守衛(wèi)之路由獨(dú)享守衛(wèi)

    這篇文章主要介紹了Vue路由守衛(wèi)之路由獨(dú)享守衛(wèi)的代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-09-09
  • 淺談Vuex的狀態(tài)管理(全家桶)

    淺談Vuex的狀態(tài)管理(全家桶)

    本篇文章主要介紹了淺談Vuex狀態(tài)管理(全家桶),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11
  • 簡(jiǎn)單理解vue中Props屬性

    簡(jiǎn)單理解vue中Props屬性

    這篇文章主要幫助大家簡(jiǎn)單的理解vue中Props屬性,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • vue3+ts+vite2項(xiàng)目實(shí)戰(zhàn)踩坑記錄

    vue3+ts+vite2項(xiàng)目實(shí)戰(zhàn)踩坑記錄

    最近嘗試上手Vue3+TS+Vite,對(duì)比起Vue2有些不適應(yīng),但還是真香,下面這篇文章主要給大家介紹了關(guān)于vue3+ts+vite2項(xiàng)目的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09
  • Vue項(xiàng)目中props傳值時(shí)子組件檢測(cè)不到的問題及解決

    Vue項(xiàng)目中props傳值時(shí)子組件檢測(cè)不到的問題及解決

    這篇文章主要介紹了Vue項(xiàng)目中props傳值時(shí)子組件檢測(cè)不到的問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • vue中的data,computed,methods,created,mounted用法及說明

    vue中的data,computed,methods,created,mounted用法及說明

    這篇文章主要介紹了vue中的data,computed,methods,created,mounted用法及說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • vue-router中query取值的坑及解決

    vue-router中query取值的坑及解決

    這篇文章主要介紹了vue-router中query取值的坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • vue3+elementplus 樹節(jié)點(diǎn)過濾功能實(shí)現(xiàn)

    vue3+elementplus 樹節(jié)點(diǎn)過濾功能實(shí)現(xiàn)

    樹節(jié)點(diǎn)所展示的街道是讀取的成都市金牛區(qū)的范圍邊界線的json文件,街道下對(duì)應(yīng)內(nèi)容市通過fetch調(diào)用接口獲取的內(nèi)容,通過mapTreeData函數(shù)循環(huán)遍歷,對(duì)數(shù)據(jù)進(jìn)行處理,這篇文章主要介紹了vue3+elementplus 樹節(jié)點(diǎn)過濾功能實(shí)現(xiàn),需要的朋友可以參考下
    2024-05-05
  • Vant?UI中van-collapse下拉折疊面板默認(rèn)展開第一項(xiàng)的方法

    Vant?UI中van-collapse下拉折疊面板默認(rèn)展開第一項(xiàng)的方法

    之前做項(xiàng)目的時(shí)候,使用了Collapse折疊面板,下面這篇文章主要給大家介紹了關(guān)于Vant?UI中van-collapse下拉折疊面板默認(rèn)展開第一項(xiàng)的相關(guān)資料,需要的朋友可以參考下
    2022-03-03

最新評(píng)論