2021-08-02 15:22:04 +08:00
|
|
|
---
|
|
|
|
order: 6
|
|
|
|
title:
|
|
|
|
zh-CN: 相册模式
|
|
|
|
en-US: Preview from one image
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
从一张图片点开相册。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Preview a collection from one image.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2021-08-02 15:22:04 +08:00
|
|
|
import { Image } from 'antd';
|
2022-05-21 22:14:15 +08:00
|
|
|
import React, { useState } from 'react';
|
2021-08-02 15:22:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
2021-08-02 15:22:04 +08:00
|
|
|
const [visible, setVisible] = useState(false);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
2021-08-02 15:22:04 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Image
|
|
|
|
preview={{ visible: false }}
|
|
|
|
width={200}
|
|
|
|
src="https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp"
|
|
|
|
onClick={() => setVisible(true)}
|
|
|
|
/>
|
|
|
|
<div style={{ display: 'none' }}>
|
|
|
|
<Image.PreviewGroup preview={{ visible, onVisibleChange: vis => setVisible(vis) }}>
|
|
|
|
<Image src="https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp" />
|
|
|
|
<Image src="https://gw.alipayobjects.com/zos/antfincdn/cV16ZqzMjW/photo-1473091540282-9b846e7965e3.webp" />
|
|
|
|
<Image src="https://gw.alipayobjects.com/zos/antfincdn/x43I27A55%26/photo-1438109491414-7198515b166b.webp" />
|
|
|
|
</Image.PreviewGroup>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2021-08-02 15:22:04 +08:00
|
|
|
```
|