2020-03-15 20:53:23 +08:00
|
|
|
---
|
|
|
|
order: 10
|
|
|
|
title: useBreakpoint Hook
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
使用 `useBreakpoint` Hook 个性化布局。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2020-05-07 23:22:31 +08:00
|
|
|
Use `useBreakpoint` Hook provide personalized layout.
|
2020-03-15 20:53:23 +08:00
|
|
|
|
|
|
|
```jsx
|
2020-04-27 16:59:33 +08:00
|
|
|
import { Grid, Tag } from 'antd';
|
2020-03-15 20:53:23 +08:00
|
|
|
|
|
|
|
const { useBreakpoint } = Grid;
|
|
|
|
|
|
|
|
function UseBreakpointDemo() {
|
|
|
|
const screens = useBreakpoint();
|
|
|
|
return (
|
2020-04-27 16:59:33 +08:00
|
|
|
<>
|
|
|
|
Current break point:{' '}
|
|
|
|
{Object.entries(screens)
|
|
|
|
.filter(screen => !!screen[1])
|
|
|
|
.map(screen => (
|
|
|
|
<Tag color="blue" key={screen[0]}>
|
|
|
|
{screen[0]}
|
|
|
|
</Tag>
|
|
|
|
))}
|
|
|
|
</>
|
2020-03-15 20:53:23 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<UseBreakpointDemo />, mountNode);
|
|
|
|
```
|