2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 0
|
2016-07-10 08:56:02 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 基本
|
|
|
|
en-US: Basic
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-08-03 16:49:42 +08:00
|
|
|
|
2016-07-10 08:56:02 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-08-03 16:49:42 +08:00
|
|
|
最简单的用法。
|
|
|
|
|
2016-07-10 08:56:02 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
The simplest usage.
|
|
|
|
|
2020-01-03 11:55:35 +08:00
|
|
|
```tsx
|
2020-01-22 12:11:49 +08:00
|
|
|
import React, { useState } from 'react';
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Affix, Button } from 'antd';
|
2015-08-03 16:49:42 +08:00
|
|
|
|
2020-01-21 17:14:58 +08:00
|
|
|
const Demo: React.FC = () => {
|
2020-01-22 12:11:49 +08:00
|
|
|
const [top, setTop] = useState(10);
|
|
|
|
const [bottom, setBottom] = useState(10);
|
2020-01-03 11:55:35 +08:00
|
|
|
|
|
|
|
return (
|
2020-06-17 11:51:06 +08:00
|
|
|
<>
|
2020-01-06 11:13:39 +08:00
|
|
|
<Affix offsetTop={top}>
|
|
|
|
<Button type="primary" onClick={() => setTop(top + 10)}>
|
|
|
|
Affix top
|
|
|
|
</Button>
|
|
|
|
</Affix>
|
|
|
|
<br />
|
|
|
|
<Affix offsetBottom={bottom}>
|
|
|
|
<Button type="primary" onClick={() => setBottom(bottom + 10)}>
|
|
|
|
Affix bottom
|
|
|
|
</Button>
|
|
|
|
</Affix>
|
2020-06-17 11:51:06 +08:00
|
|
|
</>
|
2020-01-06 11:13:39 +08:00
|
|
|
);
|
|
|
|
};
|
2018-06-15 17:53:08 +08:00
|
|
|
|
2022-04-03 23:27:45 +08:00
|
|
|
export default () => <Demo />;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|