1.2.0 • Published 4 years ago

lang-virtual-list-vue v1.2.0

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

lang-virtual-list-vue

一个基于Vue2.6+的虚拟列表组件,可同时加载大量数据,并支持动态高度。

安装

通过 npm:

npm install lang-virtual-list-vue --save

基本使用

<template>
    <virtual-list
        :list-data="data"
        :estimated-item-size="100"
        v-slot="slotProps"
    >
        <div>
            {{ slotProps.item }}{{ slotProps.index }}
        </div>
    </virtual-list>
</template>
import virtualList from 'lang-virtual-list-vue'

export default{
    data(){
			return {
				data: [
					'This is mounted demo1',
					'This is mounted demo2'
				]
			}
    },
    component:{
        virtualList
    }
}

下拉刷新

<template>
    <virtual-list
        ref="vlist"
        :list-data="data"
        :estimated-item-size="100"
        :top-load-more="true"
        :top-method="update"
        v-slot="slotProps"
    >
        <div>
            {{ slotProps.item }}{{ slotProps.index }}
        </div>
    </virtual-list>
</template>
import virtualList from 'lang-virtual-list-vue'

export default{
    data(){
        return {
					data: [
						'This is mounted demo1',
						'This is mounted demo2'
					]
				}
    },
    methods:{
        update(){
            let data = [
							'This is update demo1',
							'This is update demo2'
            ];
            this.data = data;
            this.$refs.vlist.onTopLoaded();
        },
    },
    component:{
        virtualList
    }
}

属性

参数类型默认值是否必填说明
listDataArray列表所需要的数据
heightString100%包裹元素的高度。
columnNumber1列数
bufferScaleNumber1在可见区域之外的上/下方预渲染比例,避免快速滑动时出现闪烁
estimatedItemSizeNumber150列表项的预估高度,用于预先计算可视区域的显示项数
topLoadMoreBooleanfalse是否启用下拉刷新
topMethodFunction刷新时调用的回调函数
topDistanceNumber70触发 topMethod 的下拉距离阈值(像素)
maxDistanceNumber0组件可移动的最大距离(像素),若为 0 则不限制
distanceScaleNumber2手指移动与组件移动距离的比值
topTextColorString#000000刷新区域的文本颜色
topPullTextString下拉刷新刷新状态为pull时提示区的文字
topDropTextString释放更新刷新状态为drop时提示区的文字
topLoadingTextString加载中...刷新状态为loading时提示区的文字
bottomLoadingTextString加载中...上滑加载更多状态为loading时提示区的文字

事件

事件名称回调参数说明
top-status-change顶部刷新区域状态变更时触发提示区域状态
onTopLoaded绑定ref后下拉加载数据后手动触发取消loading状态
onBottomLoaded绑定ref后上滑加载数据后手动触发取消loading状态

提示区状态说明

状态说明
pull开始拖拽,距离未达到topDistance
drop距离达到 topDistance 释放触发 topMethod
loading已被释放,topMethod 已经执行
none刷新完成或未触发刷新动作

插槽

名称说明插槽Prop
default默认插槽item:列表项当前数据row:当前项在整体中的行数col:当前项在当前行中的列数
top顶部提示区插槽dargState:顶部刷新提示区的状态dargDistance:顶部刷新提示区的距离
1.2.0

4 years ago

1.1.7

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.9

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.7

4 years ago

0.7.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.6.0

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago