1.0.5 • Published 3 years ago

infinite-loading-vue3-ts v1.0.5

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

infinite-loading-vue3-ts

While waiting new version support vue 3 from: https://www.npmjs.com/package/vue-infinite-loading

I make a new one, is based on the package above for vue 3

Install

npm i infinite-loading-vue3-ts

API

slots

  • spinner: loading here
  • no-more: text no more
  • no-results: text no results

events

  • infinite: is call from the component

Usage & Example

Then, import and using the component in .vue file.

Here is an example how using the component:

<template>
  ...
  <infinite-loading
    @infinite="infiniteHandler"
  >
    <template #spinner>
      // loading here
    </template>
    <template #no-more>
      // text no more
    </template>
    <template #no-results>
      // text no results
    </template>
  </infinite-loading>
</template>

<script lang="ts">
import InfiniteLoading from 'infinite-loading-vue3-ts';

export default defineComponent({
  components: {
    InfiniteLoading,
  },
  data() {
    return {
      page: 1,
      list: [],
    };
  },
  methods: {
    infiniteHandler($state: any):void {
      axios.get(api, {
        params: {
          page: this.page,
        },
      }).then(({ data }) => {
        if (data.hits.length) {
          this.page += 1;
          this.list.push(...data.hits);
          
          $state.loaded();
        } else {
          $state.complete();
        }
      });
    },
  },
});
</script>

Refs

This package gets ideas from https://www.npmjs.com/package/vue-infinite-loading If you want to know in deep let's go and read their great document

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago