Skip to content

Commit d12edae

Browse files
authored
docs(image): add controlled preview demo (#5234)
1 parent 34869ec commit d12edae

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

components/image/__tests__/__snapshots__/demo.test.js.snap

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ exports[`renders ./components/image/demo/basic.vue correctly 1`] = `
77
</div>
88
`;
99
10+
exports[`renders ./components/image/demo/controlledPreview.vue correctly 1`] = `
11+
<div><button class="ant-btn ant-btn-primary" type="button">
12+
<!----><span>show image preview</span>
13+
</button>
14+
<div class="ant-image" style="width: 200px;"><img class="ant-image-img" style="display: none;" src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png">
15+
<!---->
16+
<!---->
17+
</div>
18+
<!---->
19+
</div>
20+
`;
21+
1022
exports[`renders ./components/image/demo/fallback.vue correctly 1`] = `
1123
<div class="ant-image" style="width: 200px; height: 200px;"><img class="ant-image-img" src="https://www.antdv.com/#error">
1224
<!---->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<docs>
2+
---
3+
order: 4
4+
title:
5+
zh-CN: 受控的预览
6+
en-US: Controlled Preview
7+
---
8+
9+
## zh-CN
10+
11+
可以使预览受控。
12+
13+
## en-US
14+
15+
You can make preview controlled.
16+
17+
</docs>
18+
19+
<template>
20+
<div>
21+
<a-button type="primary" @click="() => setVisible(true)">show image preview</a-button>
22+
<a-image
23+
:width="200"
24+
:style="{ display: 'none' }"
25+
:preview="{
26+
visible,
27+
onVisibleChange: setVisible,
28+
}"
29+
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
30+
/>
31+
</div>
32+
</template>
33+
<script lang="ts">
34+
import { defineComponent, ref } from 'vue';
35+
export default defineComponent({
36+
setup() {
37+
const visible = ref<boolean>(false);
38+
const setVisible = (value): void => {
39+
visible.value = value;
40+
};
41+
return {
42+
visible,
43+
setVisible,
44+
};
45+
},
46+
});
47+
</script>

components/image/demo/index.vue

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<fallback />
55
<placeholder />
66
<preview-group />
7+
<controlled-preview />
78
</demo-sort>
89
</template>
910

@@ -12,6 +13,7 @@ import Basic from './basic.vue';
1213
import Fallback from './fallback.vue';
1314
import Placeholder from './placeholder.vue';
1415
import PreviewGroup from './previewGroup.vue';
16+
import ControlledPreview from './controlledPreview.vue';
1517
1618
import CN from '../index.zh-CN.md';
1719
import US from '../index.en-US.md';
@@ -24,6 +26,7 @@ export default defineComponent({
2426
Fallback,
2527
Placeholder,
2628
PreviewGroup,
29+
ControlledPreview,
2730
},
2831
});
2932
</script>

0 commit comments

Comments
 (0)