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

43 lines
703 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
import { Affix, Button } from 'antd';
2022-05-23 14:37:16 +08:00
import React, { useState } from 'react';
2015-08-03 16:49:42 +08:00
const App: 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 App;
2019-05-07 14:57:32 +08:00
```