<template>
<el-scrollbar
ref="infiniteScroll"
class="info_scroll j-infiniteScroll"
:
>
<template v-if="data.status === 'success'">
<div >
<slot></slot>
</div>
<div
v-if="!data.disabled && !$slots.turnpage"
class="flex_center turnpage noselect"
@click="clickSubmit"
>
<i
class="el-icon-loading"
v-if="data.loading"
></i>
{{ bottomText }}
</div>
<slot name="turnpage"></slot>
</template>
<template v-else-if="data.status === 'error'">
<slot name="error" v-if="$"></slot>
<el-result icon="error" title="提⽰" :subTitle="Tip" v-else>        <el-button slot="extra" type="primary" @click="load('auto')">刷新
</el-button>
</el-result>
</template>
</el-scrollbar>
</template>
<script>
import dataDefa from "./dataDefa";
export default {
name: "infiniteScroll",
props: {木兰诗翻译
data: {
type: Object,
default: () => dataDefa,
},
},
computed: {
// 设置宽⾼
林峰家庭
sty() {
return {
width: this.data.width || "100%",
height: this.data.height || "500px",
};
},
// 底部⽂本
bottomText() {
// 禁⽤
if (this.data.disabled) return "";
// 加载
if (this.data.loading) return this.data.loadText;
// 加载失败
if (this.data.loadFail) return this.data.loadFailText;
// 没有数据时
if (
ptyAuto &&
男孩好名字this.data.page * this.data.pageSize >= al
) {
return ptyText;
}
// 默认
return this.data.defaText;
},
// 距离底部距离
distance() {
const distance = (this.data.distance || 30) * 1;
const distance = (this.data.distance || 30) * 1;
return isNaN(distance) ? 30 : distance >= 0 ? distance : 0;
},
// 滚动节流毫秒
delay() {
const delay = (this.data.delay || 200) * 1;
return isNaN(delay) ? 200 : delay >= 0 ? delay : 0;
},
},
data() {
return {
delayTimeOuts: null,
};
},
mounted() {
if (this.data.auto) this.load("auto");
this.$refs.infiniteScroll.$scroll = this.scrollSubmit;
},
methods: {
/**
* @description: 加载
* @param {any} type auto是⾃动触发,clickBottom点击底部按钮触发,scrollBottom滚动底部触发,其它根据业务⾃定义处理    * @return {void}
*/
load(type) {
if (type === "auto") this.data.page = 1;
this.$emit("load", Object.assign(this.data, { type }));
},
/**
* @description: 点击触发加载下⼀页
* @param {void}
* @return {void}
*/
陈倩扬老公
clickSubmit() {兽兽翻脸门
if (this.data.page * this.data.pageSize >= al) {
ptyAuto = true;
return;
}
this.data.page += 1;
this.load("clickBottom");
},
/**
* @description: 滚动时触发
* @param {void}
* @return {void}
*/
scrollSubmit() {
if (
this.data.disabled ||
!this.data.auto ||
this.data.status !== "success"
)谌龙怎么读
return;
if (this.data.page * this.data.pageSize >= al) {
ptyAuto = true;
return;
}
clearTimeout(this.delayTimeOuts);
this.delayTimeOuts = setTimeout(() => {
let { offsetHeight, scrollTop, scrollHeight } =
this.$refs.infiniteScroll.$refs.wrap;
scrollHeight = scrollHeight - this.distance;
if (offsetHeight + scrollTop >= scrollHeight) {
this.data.page += 1;
this.load("scrollBottom");
}
}, this.delay);
},
},
};
</script>
<style lang='less' scoped>
.j-infiniteScroll {