1.2.3 • Published 5 years ago

vue-dropdownload v1.2.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

vue-dropdownload

基于vue,一个简单的下拉滚动加载的插件

##安装

npm install --save vue-dropdownload

##使用方法

import dropdownLoad from 'vue-dropdownload'
Vue.use(dropdownLoad)
例如home.vue
<template>
  <dropdown ref="dropdownload" :options="options" @load="onLoadCallback">
    <div class="your-vue-content">你的内容</div>
  </dropdown>
</template>
<script>
export default {
	data() {
		return {
			// dropdown接收一个options props, 参数为offset[滚动到底部的距离值] 默认30
			options: {
				offset: 50
			}
		}
	},
	methods: {
		/** [onLoadCallback description]
		* 下拉到指定的距离触发回调函数
		* - true 代表当前所有数据加载完成
		* - false 代表当前分页后面还需要继续分页加载		
		*/
		onLoadCallback() {
			// 你的请求代码......
			if (当前是最后一页) {
				this.$refs.dropdownload.$emit('updated', false)
			} else {
				this.$refs.dropdownload.$emit('updated', true)
			}
		}
	}
}
</script>