国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

分享一個精簡的vue.js 圖片lazyload插件實例

2019-11-19 17:10:04
字體:
來源:轉載
供稿:網友

這個插件未壓縮版本只有7.62kb,很精簡,支持img標簽和background-img資源的lazyload。支持vue.js 1.0 和vue.js 2.0

安轉

$ npm install vue-lazyload --save

使用方法

//main.jsimport Vue from 'vue'// import VueLazyloadimport VueLazyload from 'vue-lazyload'//use custom directiveVue.use(VueLazyload)// use optionsVue.use(VueLazyload, { preLoad: 1.3, error: 'dist/error.png', loading: 'dist/loading.gif', attempt: 1})new Vue({ el: 'body',})
<!--your.vue--><script>export default { data () {  return {   list: [    'your_images_url',     'your_images_url',     // you can customer any image's placeholder while loading or load failed    {     src: 'your_images_url.png',     error: 'another-error.png',     loading: 'another-loading-spin.svg'    }   ]  } }}</script><template> <div class="img-list">  <ul id="container">   <li v-for="img in list">    <img v-lazy="img">   </li>  </ul> </div></template>

這里可以定制所有加載中和加載失敗加載成功的樣式,

<style> img[lazy=loading] {  /*your style here*/ } img[lazy=error] {  /*your style here*/ }, img[lazy=loaded] {  /*your style here*/ } /* or background-image */ .yourclass[lazy=loading] {  /*your style here*/ } .yourclass[lazy=error] {  /*your style here*/ }, .yourclass[lazy=loaded] {  /*your style here*/ }</style>

API

Options

params type detail
preLoad Number proportion of pre-loading height
error String error img src
loading String loading img src
attempt Number attempts count

demo下載地址:vue-lazyloadz_jb51.rar

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青海省| 伊吾县| 利津县| 阿城市| 玉门市| 吉木乃县| 喜德县| 道孚县| 武城县| 清苑县| 桃园市| 黄山市| 文昌市| 濉溪县| 临高县| 郑州市| 阳山县| 郧西县| 广饶县| 库尔勒市| 汽车| 灌阳县| 宁德市| 财经| 嵊泗县| 青铜峡市| 新邵县| 夏河县| 井陉县| 阿勒泰市| 金堂县| 乌拉特后旗| 改则县| 澄迈县| 格尔木市| 中牟县| 三河市| 阿荣旗| 泸定县| 甘谷县| 古田县|