2.7 KiB
2.7 KiB
title, description, spline, isComponent
| title | description | spline | isComponent |
|---|---|---|---|
| Sticky 吸顶 | 用于常驻页面顶部的信息、操作展示。 | data | true |
引入
全局引入,在 miniprogram 根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。
"usingComponents": {
"t-sticky": "tdesign-miniprogram/sticky/sticky"
}
代码演示
将内容包裹在 Sticky 组件内
Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"
基础吸顶
{{ base }}
吸顶距离
{{ offset }}
指定容器
{{ container }}
API
Sticky Props
| 名称 | 类型 | 默认值 | 描述 | 必传 |
|---|---|---|---|---|
| style | Object | - | 样式 | N |
| custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N |
| container | Function | - | 函数返回容器对应的 NodesRef 节点,将对应节点指定为组件的外部容器,滚动时组件会始终保持在容器范围内,当组件即将超出容器底部时,会返回原位置。 | N |
| disabled | Boolean | false | 是否禁用组件 | N |
| offset-top | String / Number | 0 | 吸顶时与顶部的距离,单位px |
N |
| z-index | Number | 99 | 吸顶时的 z-index | N |
Sticky Events
| 名称 | 参数 | 描述 |
|---|---|---|
| scroll | (detail: { scrollTop: number, isFixed: boolean }) |
滚动时触发,scrollTop: 距离顶部位置,isFixed: 是否吸顶。通用类型定义 |
Sticky External Classes
| 类名 | 描述 |
|---|---|
| t-class | 根节点样式类 |
| t-class-content | 内容样式类 |