1.引入vue-lazyload.js
2.//vue懶加載圖片
Vue.use(VueLazyload, {?
? ? preLoad: 1.3,?
? ? error:'images/error.png', //加載錯(cuò)誤的圖片
? ? loading: 'images/loading.gif', //加載中的圖片,最好找一個(gè)loading的gif
? ? attempt: 1? ,
? ? listenEvents: [ 'scroll' ]//監(jiān)聽(tīng)的事件
});?
3.html中將src改為? v-lazy='http://192.168.0.105/app/handlerapp.ashx?action=GetMaintenanceThumbnail&billID='+data.BillID+'&r='+Math.random()
4.注意后面要加入一個(gè)隨機(jī)數(shù),不然src如果認(rèn)為網(wǎng)址一樣的話,就不去刷新了