1.0.9 • Published 5 years ago

vue-directive-lazy v1.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Vue 2.0 懒加载指令 ( Vue lazyload directive )

轻量级 Vue 2.0 懒加载自定义指令; 支持懒加载dom属性; 支持懒加载函数调用; 资源合理释放;

安装:

  • ES6
 
npm install vue-directive-lazy --save; 
yarn add vue-directive-lazy;
import lazy from 'vue-directive-lazy';
Vue.use(lazy,{
    error: '',
    loading: ''
});

Constructor Options

keydescriptiondefaultoptions
errorsrc of the image upon load failString
loadingsrc of the image while loadingdata:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=String

error 参数为空情况下,图片加载失败将默认展示 loading 参数的图片

  • 直接引入:
<script src="./vue.js"></script>
<script src="./dist/index.js"></script>

使用 How to use:

常规

<p v-lazy:class="className">延迟绑定className,className会追加在已有class内</p>

<img v-lazy:src="imgSrc">延迟加载图片</p>

<div v-lazy:method="trigger">触发函数调用</div>
new Vue({
	el: "dom",
	data() {
	    return {
	        className: 'customClass',
	        imgSrc: 'http://img.jpg'
	    }
	},
	methods: {
	    trigger: function() {
	        // do something
	    }
	}
});

License

MIT

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago