2020-08-22 22:02:20 +08:00
|
|
|
---
|
|
|
|
order: 3
|
|
|
|
title:
|
|
|
|
zh-CN: 渐进加载
|
|
|
|
en-US: Progressive Loading
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
大图使用 placeholder 渐进加载。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Progressive when large image loading.
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import React from 'react';
|
2020-09-30 16:46:44 +08:00
|
|
|
import { Image, Button, Space } from 'antd';
|
2020-08-22 22:02:20 +08:00
|
|
|
|
|
|
|
function ImageDemo() {
|
|
|
|
const [random, setRandom] = React.useState();
|
|
|
|
return (
|
2020-09-30 16:46:44 +08:00
|
|
|
<Space size={12}>
|
2020-08-22 22:02:20 +08:00
|
|
|
<Image
|
|
|
|
width={200}
|
|
|
|
src={`https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?${random}`}
|
|
|
|
placeholder={
|
|
|
|
<Image
|
|
|
|
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?x-oss-process=image/blur,r_50,s_50/quality,q_1/resize,m_mfit,h_200,w_200"
|
|
|
|
width={200}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
onClick={() => {
|
|
|
|
setRandom(Date.now());
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Reload
|
|
|
|
</Button>
|
2020-09-30 16:46:44 +08:00
|
|
|
</Space>
|
2020-08-22 22:02:20 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<ImageDemo />, mountNode);
|
|
|
|
```
|