You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
---
|
|
|
|
order: 0
|
|
|
|
title:
|
|
|
|
zh-CN: 基本
|
|
|
|
en-US: Basic
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
最简单的用法。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
The simplest usage.
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { Affix, Button } from 'antd';
|
|
|
|
|
|
|
|
class Demo extends React.Component {
|
|
|
|
state = {
|
|
|
|
top: 10,
|
|
|
|
bottom: 10,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Affix offsetTop={this.state.top}>
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
onClick={() => {
|
|
|
|
this.setState({
|
|
|
|
top: this.state.top + 10,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Affix top
|
|
|
|
</Button>
|
|
|
|
</Affix>
|
|
|
|
<br />
|
|
|
|
<Affix offsetBottom={this.state.bottom}>
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
onClick={() => {
|
|
|
|
this.setState({
|
|
|
|
bottom: this.state.bottom + 10,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Affix bottom
|
|
|
|
</Button>
|
|
|
|
</Affix>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
```
|