vue-super-scroller
v1.0.24
Published
基于vue 2.0 上下拉组件
Downloads
15
Readme
vue-super-scroller
Table of contents
Installation
npm install vue-super-scroller --save
Global Install
Install all the components:
import Vue from 'vue'
import VueSuperScroller from 'vue-super-scroller'
Vue.use(VueSuperScroller)
Usage
:load-disabled="!hasNext"
:on-refresh="refresh"
:on-load='loadMore'
Example
<template>
<div id="app">
<vue-scroller :load-disabled="!hasNext" :on-refresh="refresh" :on-load='loadMore'>
<li v-for="(item,index) in lists">{{item}}</li>
</vue-scroller>
</div>
</template>
<script>
export default {
name: 'app',
components: {},
data () {
return {
lists: [1, 2, 3],
hasNext: true
}
},
mounted () {
this.$nextTick(function () {
this.loadMore()
})
},
methods: {
getRandArr (num = 20) {
let arr = []
for (let i = num - 1; i >= 0; i--) {
arr.push(Math.round(Math.random() * 100))
}
return arr
},
refresh (call) {
setTimeout(() => {
this.lists = [1, 2, 3]
call(true)
}, 1000)
},
loadMore () {
setTimeout(() => {
this.lists = this.lists.concat(this.getRandArr(20))
if (this.lists.length > 50) {
this.hasNext = false
}
}, 1000)
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
li {
height: 150px;
text-align: center;
line-height: 150px;
font-size: 30px;
}
li:nth-child(odd) {
background-color: #eee
}
</style>