2019-07-16 20:48:03 +08:00
|
|
|
---
|
|
|
|
order: 99
|
|
|
|
title:
|
2020-01-03 11:55:35 +08:00
|
|
|
zh-CN: 调整浏览器大小,观察 Affix 容器是否发生变化。跟随变化为正常。#17678
|
2020-08-05 14:50:52 +08:00
|
|
|
en-US: debug
|
2019-07-17 11:11:55 +08:00
|
|
|
debug: true
|
2019-07-16 20:48:03 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
DEBUG
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
DEBUG
|
|
|
|
|
2020-01-03 11:55:35 +08:00
|
|
|
```tsx
|
2020-01-22 12:11:49 +08:00
|
|
|
import React, { useState } from 'react';
|
2019-07-16 20:48:03 +08:00
|
|
|
import { Affix, Button } from 'antd';
|
|
|
|
|
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);
|
2020-01-03 11:55:35 +08:00
|
|
|
return (
|
|
|
|
<div style={{ height: 10000 }}>
|
|
|
|
<div>Top</div>
|
|
|
|
<Affix offsetTop={top}>
|
|
|
|
<div style={{ background: 'red' }}>
|
2020-01-06 11:13:39 +08:00
|
|
|
<Button type="primary" onClick={() => setTop(top + 10)}>
|
2020-01-03 11:55:35 +08:00
|
|
|
Affix top
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Affix>
|
|
|
|
<div>Bottom</div>
|
|
|
|
</div>
|
|
|
|
);
|
2020-01-06 11:13:39 +08:00
|
|
|
};
|
2019-07-16 20:48:03 +08:00
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
```
|