loadmore 7.23
This commit is contained in:
61
components/loadmore/index.vue
Normal file
61
components/loadmore/index.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<view class="loadmore">
|
||||
<u-loadmore :status="loadStatus" :bgColor="bgColor" margin-bottom="20"></u-loadmore>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/*
|
||||
* @description 下拉加载
|
||||
* @property {String} bgColor 背景色
|
||||
* @property {Number} page 初始页码
|
||||
* @event {Function} callback 下拉刷新请求的接口
|
||||
**/
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loadStatus: 'loadmore',
|
||||
timer: true,
|
||||
tpage: Number,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
bgColor: String,
|
||||
page: Number,
|
||||
},
|
||||
created() {
|
||||
this.tpage = this.page;
|
||||
},
|
||||
methods: {
|
||||
reachBottom() {
|
||||
if(!this.timer) return false;
|
||||
this.loadStatus = "loading";
|
||||
this.tpage++;
|
||||
this.$emit('callback', { page: this.tpage });
|
||||
// this.$emit('callback', { page: this.tpage }).then(length => {
|
||||
// if(length == 0) {
|
||||
// this.tpage--;
|
||||
// this.status = 'nomore';
|
||||
// } else {
|
||||
// this.status = 'loading';
|
||||
// }
|
||||
// }).catch(() => {
|
||||
// this.loadStatus = "nomore";
|
||||
// this.tpage--;
|
||||
// })
|
||||
// this.$parent.callback({ page: this.tpage }).then(length => {
|
||||
// if(length == 0) {
|
||||
// this.tpage--;
|
||||
// this.status = 'nomore';
|
||||
// } else {
|
||||
// this.status = 'loading';
|
||||
// }
|
||||
// }).catch(() => {
|
||||
// this.loadStatus = "nomore";
|
||||
// this.tpage--;
|
||||
// })
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user