# ui-sticky 粘性定位组
版本:v2.3.11
粘性定位组件用于将元素固定在指定位置,支持自定义偏移量和触发条件
# 基本使用
<template>
<div class="sticky-demo">
<div style="height: 200px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;">
滚动下方内容查看粘性定位效
</div>
<ui-sticky>
<div style="background: #1989fa; color: white; padding: 16px; text-align: center;">
这是一个粘性定位元
</div>
</ui-sticky>
<div style="height: 1000px; background: #fff; padding: 20px;">
<h3>内容区域</h3>
<p>向下滚动查看粘性定位效..</p>
</div>
</div>
</template>
<style scoped>
.sticky-demo {
padding: 20px;
}
</style>
# Props
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
offsetTop | Number | 0 | 距离顶部的偏移量,单位:px |
offsetBottom | Number | - | 距离底部的偏移量,单位:px |
zIndex | Number | 100 | 粘性元素层 |
disabled | Boolean | false | 是否禁用粘性定 |
# Events
| 事件 | 说明 | 回调参数 |
|---|---|---|
change | 粘性状态变化时触发 | (isSticky: Boolean) 是否处于粘性状 |