Skip to content

Commit 29443ae

Browse files
committed
fix(Image): can not cancel previewMask
1 parent 728bfe6 commit 29443ae

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

components/image/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Previewable image.
2222
| placeholder | Load placeholder, use default placeholder when set `true` | boolean \| slot | - | 2.0.0 |
2323
| preview | preview config, disabled when `false` | boolean \| [previewType](#previewType) | true | 2.0.0 |
2424
| src | Image path | string | - | 2.0.0 |
25-
| previewMask | custom mask | slot | - | 3.2.0 |
25+
| previewMask | custom mask | boolean \| VNode \| VNode[] \| slot | true | 3.2.0 |
2626
| width | Image width | string \| number | - | 2.0.0 |
2727

2828
### events

components/image/index.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App, ExtractPropTypes, ImgHTMLAttributes, Plugin } from 'vue';
2-
import { defineComponent, computed } from 'vue';
2+
import { defineComponent, computed, isVNode } from 'vue';
33
import ImageInternal from '../vc-image';
44
import { imageProps } from '../vc-image/src/Image';
55
import defaultLocale from '../locale/en_US';
@@ -49,13 +49,17 @@ const Image = defineComponent<ImageProps>({
4949
v-slots={{
5050
...slots,
5151
previewMask:
52-
slots.previewMask ??
53-
(() => (
54-
<div class={`${prefixCls.value}-mask-info`}>
55-
<EyeOutlined />
56-
{imageLocale?.preview}
57-
</div>
58-
)),
52+
props.previewMask === false
53+
? null
54+
: isVNode(props.previewMask)
55+
? props.previewMask
56+
: slots.previewMask ??
57+
(() => (
58+
<div class={`${prefixCls.value}-mask-info`}>
59+
<EyeOutlined />
60+
{imageLocale?.preview}
61+
</div>
62+
)),
5963
}}
6064
></ImageInternal>
6165
);

components/image/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg
2323
| placeholder | 加载占位, 为 `true` 时使用默认占位 | boolean \| slot | - | 2.0.0 |
2424
| preview | 预览参数,为 `false` 时禁用 | boolean \| [previewType](#previewType) | true | 2.0.0 |
2525
| src | 图片地址 | string | - | 2.0.0 |
26-
| previewMask | 自定义 mask | slot | - | 3.2.0 |
26+
| previewMask | 自定义 mask | boolean \| VNode \| VNode[] \| slot | true | 3.2.0 |
2727
| width | 图像宽度 | string \| number | - | 2.0.0 |
2828

2929
### 事件

components/vc-image/src/Image.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ImgHTMLAttributes, CSSProperties, PropType } from 'vue';
1+
import type { ImgHTMLAttributes, CSSProperties, PropType, VNode } from 'vue';
22
import { ref, watch, defineComponent, computed, onMounted, onUnmounted } from 'vue';
33
import isNumber from 'lodash-es/isNumber';
44
import cn from '../../_util/classNames';
@@ -45,6 +45,10 @@ export const imageProps = () => ({
4545
rootClassName: String,
4646
prefixCls: String,
4747
previewPrefixCls: String,
48+
previewMask: {
49+
type: [Boolean, Object, Array] as PropType<boolean | VNode | VNode[]>,
50+
default: true,
51+
},
4852
placeholder: PropTypes.any,
4953
fallback: String,
5054
preview: {

0 commit comments

Comments
 (0)