mint-ui 上拉重新整理,下拉載入
阿新 • • 發佈:2018-12-09
export default {
data() {
return {
list: [],
allLoaded: true,
bottomStatus: "",
wrapperHeight: 0,
topStatus: "",
translate: 0,
moveTranslate: 0
};
},
methods: {
handleBottomChange(status) {
this.bottomStatus = status;
},
loadBottom() {
if (this.allLoaded) return;
setTimeout(() => {
let lastValue = this.list[this.list.length - 1];
if (lastValue < 40) {
for (let i = 1; i <= 10; i++) {
this.list.push(lastValue + i);
}
} else {
this.allLoaded = true;
}
this .$refs.loadmore.onBottomLoaded();
}, 1500);
},
handleTopChange(status) {
this.moveTranslate = 1;
this.topStatus = status;
},
translateChange(translate) {
const translateNum = +translate;
this.translate = translateNum.toFixed(2);
this.moveTranslate = (1 + translateNum / 70).toFixed(2);
},
loadTop() {
setTimeout(() => {
let firstValue = this.list[0];
for (let i = 1; i <= 10; i++) {
this.list.unshift(firstValue - i);
}
this.$refs.loadmore.onTopLoaded();
}, 1500);
}
},
created() {
setTimeout(() => {
for (let i = 1; i <= 20; i++) {
this.list.push(i);
}
this.allLoaded = false;
this.$refs.loadmore.onBottomLoaded();
}, 1500);
},
mounted() {
this.wrapperHeight =
document.documentElement.clientHeight -
this.$refs.wrapper.getBoundingClientRect().top;
}
};