CursorTip
用于模拟 title 属性的 CursorTip 悬浮提示组件。
基础用法
通过 content 显示悬浮展示的文本。
function App() {
return (
<CursorTip content="这是悬浮显示的提示文本">
<Button>悬浮提示</Button>
</CursorTip>
);
}
控制持续时间
通过 duration 控制悬浮展示的持续时间。
function App() {
return (
<CursorTip content="这是悬浮显示的提示文本" duration={3}>
<Button>悬浮提示</Button>
</CursorTip>
);
}
位置更新频率
通过 frequency 控制悬浮展示的位置更新频率。
function App() {
return (
<CursorTip content="这是悬浮显示的提示文本" frequency={200}>
<Button>悬浮提示</Button>
</CursorTip>
);
}
渐入浅出时间
通过 transTime 控制悬浮展示的渐入浅出时间,单位为毫秒。
function App() {
return (
<CursorTip content="这是悬浮显示的提示文本" transTime={100}>
<Button>悬浮提示</Button>
</CursorTip>
);
}
位置偏移量
通过 offset 控制悬浮展示的位置偏移量。
function App() {
return (
<CursorTip content="这是悬浮显示的提示文本" offset={[100, 100]}>
<Button>悬浮提示</Button>
</CursorTip>
);
}
提示层级
通过 zIndex 控制悬浮展示的提示层级。
function App() {
return (
<CursorTip content="这是悬浮显示的提示文本" zIndex={999}>
<Button>悬浮提示</Button>
</CursorTip>
);
}
API
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| children | 内容 | ReactNode | -- |
| className | 类名 | string | -- |
| style | 样式 | CSSProperties | -- |
| content | 提示文本 | ReactNode | -- |
| duration | 持续时间,单位为秒 | number | -- |
| frequency | 位置更新频率,单位为毫秒 | number | 1 |
| transTime | 渐入浅出时间,单位为毫秒 | number | 200 |
| offset | 位置偏移量 | Array<string〡number> | [0, 0] |
| zIndex | 提示层级 | number | 1000 |