提交 cf940121 编写于 作者: 雪洛's avatar 雪洛

fix: 修复吸顶位置不正确的Bug

上级 92c41735
<template>
<scroll-view @scroll="onScroll" class="page" rebound="false">
<scroll-view ref="scroll" @scroll="onScroll" class="page" rebound="false">
<view class="content-item">
<text class="text">向上滑动页面,体验元素吸顶效果。</text>
</view>
......@@ -71,8 +71,9 @@
// let rect = this.stickyNode?.getBoundingClientRect();
// this.stickyTop = rect?.top;
//this.stickyTop = this.stickyNode?.getBoundingClientRect()?.top;
let rect = (this.$refs['sticky'] as Element).getBoundingClientRect();
this.stickyTop = rect.top;
const stickyRect = (this.$refs['sticky'] as Element).getBoundingClientRect();
const scrollRect = (this.$refs['scroll'] as Element).getBoundingClientRect();
this.stickyTop = stickyRect.top - scrollRect.top;
}
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册