vue-data-loading
中文文档Another component for infinite scroll and pull down/up to load data.
Here is a demo: HackNews

Install
npm install vue-data-loading --save
Usage
Import first:import VueDataLoading from 'vue-data-loading'
Register as a component:components: {
VueDataLoading
},
The only you need to do is wrapping your data with vue-data-loading
tag.<vue-data-loading>
<ul>
<li v-for="(item, index) in list" :key="index">Item: {{item}}</li>
</ul>
</vue-data-loading>
However, you can pass some props
or events
to the component.<vue-data-loading :loading="loading" :listens="['pull-down', 'infinite-scroll']" @infinite-scroll="infiniteScroll" @pull-down="pullDown">
<!--your data here-->
</vue-data-loading>
Sometimes, you may want to change the default style or text(html), that is easy, just edit the slot
:Here is a example for
infinite-scroll-loading
slot:default:
<slot :name="infinite-scroll-loading">加载中...</slot>
edit:<div slot="infinite-scroll-loading" class="some-style-you-like">
<img src="/path/to/your-icon.png">
<span>loading...</span>
</div>
Here is a full exampleAPI
Props
loading
Type: booleanDefault: false
The component will not trigger any events while
loading
is true
.It should be
true
when data are downloading, and false
when finished.completed
Type: booleanDefault: false
The component will not trigger
infinite-scroll
if true
.It should be
true
when all data have be loaded.init-scroll
Type: booleanDefault: false
The component will trigger
infinite-scroll
once if true
when it has be mounted.It uses to bootstrap when page first-time loads.
distance
Type: numberDefault: 60
Unit: px
Only available for
touch*
event, when pull distance is not less than it, pull-down
or pull-up
will be triggered.offset
Type: numberDefault: 0
Unit: px
Sometimes you want to change bottom offset to trigger
infinite-scroll
in advance.listens
Type: arrayDefault: 'infinite-scroll', 'pull-down', 'pull-up'
The component will not trigger the event if it not in the list.
container
Type: stringRequired: false
All
events
bind on window
if it is not set, or you need to specify a container ref
to it.Events
infinite-scroll
Emit when container has already scrolled to bottom of windowpull-down
Emit when container has already pulled downpull-up
Emit when container has already pulled upSlots
infinite-scroll-loading
Display when container has already scrolled to bottom of window and data isloading
pull-down-before
Display when distance ofpull-down
is less then distance
proppull-down-ready
Display when distance ofpull-down
is not less then distance
proppull-down-loading
Display when container has alreadypull-down
and data is loading
pull-up-before
Display when distance ofpull-up
is less then distance
proppull-up-ready
Display when distance ofpull-up
is not less then distance
proppull-up-loading
Display when container has alreadypull-up
and data is loading
completed
Display when data iscompleted
and not loading
Develop
# install dependencies
npm install
# serve example with hot reload at localhost:8080
npm run dev
# build vue-data-loading component
npm run dist