1.0.1 • Published 4 years ago

a-vue-virtual-list v1.0.1

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

a-vue-virtual-list

基于Vue2.6+的虚拟列表组件

安装

npm i a-vue-virtual-list

Demo

Demo Demo预览

基本使用

<template>
  <virtual-list ref="virtualList" :above-height="0" :below-height="0" :list.sync="list" 
    :refresh-load="dropRefresh" :more-load="moreLoad">
    <div slot="fixed-head" style="height: 100px;background: white"></div>
    <div slot="fixed-footer" style="height: 100px;background: white"></div>
    <template v-slot:item="{data}">
      <div style="height: 50px">{{data}}</div>
    </template>
  </virtual-list>
</template>
import VirtualList from 'ao-virtual-list-vue'

export default{
  data(){
    return {
      list: [],
        index: 0
      }
  },
  component:{
    VirtualList
  },
  methods: {
    dropRefresh () {
      return new Promise(resolve => {
        setTimeout(() => {
          this.index = 0
            this.list = []
              for (let i = 1; i < 30; i++) {
                this.list.push({
                  index: this.index
                  })
                }
              resolve()
          }, 1000)
      })
    },
    moreLoad () {
      return new Promise(resolve => {
        setTimeout(() => {
          for (let i = 1; i < 30; i++) {
            this.index++
            this.list.push({
              index: this.index
            })
          }
            resolve()
          }, 2000)
        })
      }
    }
}

传入参数props

参数类型默认值是否必填说明
listArray
refreshLoadFunctionnull下拉刷新回调(Promise)
moreLoadFunctionnull加载更多回调(Promise)
aboveHeightNumber200列表元素上方预留高度
belowHeightNumber200列表元素下方预留高度
defaultHeightNumber50初始化时使用
topBonusNumber100下拉至该值时松手刷新
listModeString'window'列表模式:'window','dom'(需要设定固定高度),'normal'(不使用虚拟列表)
domHeightNumbernulllistMode==='dom'列表高度('dom'模式时使用)

事件emit

事件名回调参数说明
changeDropState0下拉中,未下拉 1松手允许刷新 2刷新中 3加载完成下拉状态

插槽slot

名称说明插值Prop
fixed-head列表头部固定元素
dropRefreshLoading下拉刷新区,需要配合changeDropState
item列表项data:单项数据
loadingMore加载中
noMore没有更多数据(当前有数据)
noList没有数据(当前无数据)
1.0.1

4 years ago

1.0.0

4 years ago

0.9.9

4 years ago

0.9.8

4 years ago

0.9.7

4 years ago

0.9.6

4 years ago

0.9.5

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago