有下拉事件:
onPullDownRefresh: function () {}
监听屏幕距离顶部高度
onPageScroll(res) {
console.log("高度", res.scrollTop); //距离页面顶部距离
},
滚动到距离屏幕高度的距离
uni.pageScrollTo({
duration: 0, // 毫秒
scrollTop: height, // 位置
});
获取内容高度
uni.getSystemInfo({
success(res) {
_this.phoneHeight = res.windowHeight;
console.log(res.windowHeight);
// 计算组件的高度
let view = uni.createSelectorQuery().select(".i");//这标签是需要拿的标签
view
.boundingClientRect((data) => {
_this.navHeight = data.height;
_this.newh = data.height;
_this.oldh = _this.newh;
console.log(_this.oldh, _this.newh);
})
.exec();
},
});
然后直接上代码
需要在page.json设置下拉"enablePull