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

41 lines
696 B
Markdown
Raw Normal View History

2019-07-16 20:48:03 +08:00
---
order: 99
title:
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
```tsx
2019-07-16 20:48:03 +08:00
import { Affix, Button } from 'antd';
2022-05-21 22:14:15 +08:00
import React, { useState } from 'react';
2019-07-16 20:48:03 +08:00
const App: React.FC = () => {
2020-01-22 12:11:49 +08:00
const [top, setTop] = useState(10);
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)}>
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
export default App;
2019-07-16 20:48:03 +08:00
```