如上图所示,下拉正常,但是上拉加载更多不执行
问题解决:
为滚动框设置高度,并设置overflow:auto
代码如下:
computedHeight () {
const viewH = this.getViewPort().height
try {
this.listHeight = (viewH - this.$refs['list-box'].getBoundingClientRect().top - 15) + 'px'
} catch (e) {
this.listHeight = (viewH - this.$refs['list-box'].offsetTop - 15) + 'px'
}
this.$refs.loadmore.init()
},
getViewPort () {
if (document.compatMode == 'BackCompat') { // 浏览器嗅探,混杂模式
return {
width: document.body.clientWidth,
height: document.body.clientHeight
}
} else {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight
}
}
}
最外层设置样式:
.list-box{
overflow: auto;
-webkit-overflow-scrolling: touch;
}
注: 高度减15 是为了显示提示信息 “上拉加载更多”