国产探花免费观看_亚洲丰满少妇自慰呻吟_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

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 藁城市| 尤溪县| 文登市| 馆陶县| 孟连| 五家渠市| 治多县| 南陵县| 阳春市| 逊克县| 水城县| 英吉沙县| 姜堰市| 临洮县| 汤原县| 海城市| 奉贤区| 东明县| 祁门县| 潞城市| 三亚市| 桐庐县| 南部县| 丽水市| 伊吾县| 鹿邑县| 肥乡县| 邯郸县| 平阳县| 德清县| 洪湖市| 北碚区| 余庆县| 黔西| 河北省| 宜春市| 正镶白旗| 闻喜县| 周宁县| 桑日县| 潜山县|