ant-design/components/affix/demo/basic.md

43 lines
705 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 0
title:
zh-CN: 基本
en-US: Basic
2016-03-31 09:40:55 +08:00
---
2015-08-03 16:49:42 +08:00
## zh-CN
2015-08-03 16:49:42 +08:00
最简单的用法。
## en-US
The simplest usage.
```tsx
2020-01-22 12:11:49 +08:00
import React, { useState } from 'react';
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);
return (
<>
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-01-06 11:13:39 +08:00
);
};
export default Demo;
2019-05-07 14:57:32 +08:00
```