1.0.8 • Published 1 year ago

vue3-virtual-list-ts v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vue3-virtual-list

A virtual list component based on vue3 + ts

Install

npm i vue3-virtual-list-ts --save

or

yarn add vue3-virtual-list-ts

How to use

import { VirtualList } from "vue3-virtual-list-ts"

For Example

<template>
  <div>
    <div class="container">
      <VirtualList :data="data" :onCompelete="onCompelete">
        <template v-slot="{ item }">
          <div class="item" :style="{background: item.background}">
            <div>{{ item.__index__ + 1 }}</div>
          </div>
        </template>
      </VirtualList>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import VirtualList from "./index.vue";
const mock = (length = 99999) => {
  return Array.from(Array(length).keys())
  .map(i => ({
    id: i,
    text: i + '项',
    background: `rgb(${~~(Math.random() * 255)},${~~(Math.random() * 255)},${~~(Math.random() * 255)})`
  }))
}

export default defineComponent({
  name: "App",
  data() {
    return {
      data: mock()
    };
  },
  components: {
    VirtualList
  },
  methods: {
    onCompelete(){
      this.data.push(...mock(100))
    }
  }
});
</script>

<style scoped>
.container {
  width: 700px;
  height: 500px;
  margin: 0 auto;
}
.item {
  height: 40px;
  text-align: center;
  line-height: 40px;
}
</style>

Parameter

parameterdescriptiontyperequireddefault
dataarray of all dataArray
dataKeyThe key used by the loop nodestringid
itemHeightthe height of each rownumber×40
dataBufferThe amount of data retained outside the viewable areanumber×50
showLoadingshow bottom loadingboolean×true
onCompeleteTrigger callback when sliding to the bottomFunction×
1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago