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

43 lines
726 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 React, { useState, FC } from 'react';
import { Affix, Button } from 'antd';
2015-08-03 16:49:42 +08:00
const Demo: FC = () => {
const [top, setTop] = useState(10);
const [bottom, setBottom] = useState(10);
return (
<div>
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>
</div>
);
};
2018-06-27 15:55:04 +08:00
ReactDOM.render(<Demo />, mountNode);
2019-05-07 14:57:32 +08:00
```