forked from ant-design/ant-design
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add controlled preview demo for Image (ant-design#33727)
* docs: add controlled preview demo for Image * test: update snapshot * test: fix lint error
- Loading branch information
Showing
3 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
order: 7 | ||
title: | ||
zh-CN: 受控的预览 | ||
en-US: Controlled Preview | ||
--- | ||
|
||
## zh-CN | ||
|
||
可以使预览受控。 | ||
|
||
## en-US | ||
|
||
You can make preview controlled. | ||
|
||
```jsx | ||
import React, { useState } from 'react'; | ||
import { Image, Button } from 'antd'; | ||
|
||
function ImageDemo() { | ||
const [visible, setVisible] = useState(false); | ||
return ( | ||
<> | ||
<Button type="primary" onClick={() => setVisible(true)}> | ||
show image preview | ||
</Button> | ||
<Image | ||
width={200} | ||
style={{ display: 'none' }} | ||
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" | ||
preview={{ | ||
visible, | ||
src: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', | ||
onVisibleChange: value => { | ||
setVisible(value); | ||
}, | ||
}} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
ReactDOM.render(<ImageDemo />, mountNode); | ||
``` |