fix: image type error #4185

pull/4199/head
tangjinzhou 2021-06-09 22:30:32 +08:00
parent 6ae707edf5
commit 8c1979ef1b
2 changed files with 11 additions and 8 deletions

View File

@ -1,13 +1,16 @@
import { App, defineComponent, inject, Plugin } from 'vue';
import { App, defineComponent, ExtractPropTypes, ImgHTMLAttributes, inject, Plugin } from 'vue';
import { defaultConfigProvider } from '../config-provider';
import ImageInternal from '../vc-image';
import { ImageProps, ImagePropsType } from '../vc-image/src/Image';
import { imageProps } from '../vc-image/src/Image';
import PreviewGroup from './PreviewGroup';
const Image = defineComponent({
export type ImageProps = Partial<
ExtractPropTypes<typeof imageProps> & Omit<ImgHTMLAttributes, 'placeholder' | 'onClick'>
>;
const Image = defineComponent<ImageProps>({
name: 'AImage',
inheritAttrs: false,
props: ImageProps,
props: imageProps as any,
setup(props, ctx) {
const { slots, attrs } = ctx;
const configProvider = inject('configProvider', defaultConfigProvider);
@ -19,7 +22,7 @@ const Image = defineComponent({
},
});
export { ImageProps, ImagePropsType };
export { imageProps };
Image.PreviewGroup = PreviewGroup;

View File

@ -36,7 +36,7 @@ export interface ImagePropsType extends Omit<ImgHTMLAttributes, 'placeholder' |
fallback?: string;
preview?: boolean | ImagePreviewType;
}
export const ImageProps = {
export const imageProps = {
src: PropTypes.string,
wrapperClassName: PropTypes.string,
wrapperStyle: PropTypes.style,
@ -69,7 +69,7 @@ const ImageInternal = defineComponent({
name: 'Image',
mixins: [BaseMixin],
inheritAttrs: false,
props: ImageProps,
props: imageProps,
emits: ['click'],
setup(props, { attrs, slots, emit }) {
const prefixCls = computed(() => props.prefixCls);