|
@@ -44,22 +44,20 @@ export default defineComponent({
|
|
|
this.divStyle.bottom = this.offsetBottom || '0px'
|
|
|
}
|
|
|
|
|
|
- // nextTick(() => {
|
|
|
- // const { height } = useRect((this as any).$refs.div)
|
|
|
- // this.sectionStyle.height = `${height}px`
|
|
|
- // })
|
|
|
nextTick(() => {
|
|
|
setTimeout(() => {
|
|
|
const { height } = useRect((this as any).$refs.div)
|
|
|
+ console.log(height)
|
|
|
this.sectionStyle.height = `${height}px`
|
|
|
this.heightV = height
|
|
|
this.$emit('getHeight', height)
|
|
|
console.log(height, 'osticky height')
|
|
|
- }, 200)
|
|
|
+ }, 300)
|
|
|
|
|
|
- // 在次判断高度是否变化
|
|
|
+ // 为了处理头部第一次获取高度不对的问题
|
|
|
setTimeout(() => {
|
|
|
const { height } = useRect((this as any).$refs.div)
|
|
|
+ console.log(height)
|
|
|
if (height !== this.heightV) {
|
|
|
this.sectionStyle.height = `${height}px`
|
|
|
this.heightV = height
|
|
@@ -81,7 +79,6 @@ export default defineComponent({
|
|
|
return (
|
|
|
<div style={[this.sectionStyle]} class={this.mode === 'sticky' && styles.sticky}>
|
|
|
<div
|
|
|
- ref="div"
|
|
|
class={[
|
|
|
'van-sticky',
|
|
|
this.mode === 'fixed' ? 'van-sticky--fixed' : '',
|
|
@@ -89,7 +86,7 @@ export default defineComponent({
|
|
|
]}
|
|
|
style={[this.divStyle, this.sectionStyle]}
|
|
|
>
|
|
|
- {this.$slots.default && this.$slots.default()}
|
|
|
+ <div ref="div">{this.$slots.default && this.$slots.default()}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|