Browse Source

fix: image type error #4185

pull/4199/head
tangjinzhou 4 years ago
parent
commit
8c1979ef1b
  1. 15
      components/image/index.tsx
  2. 4
      components/vc-image/src/Image.tsx

15
components/image/index.tsx

@ -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;

4
components/vc-image/src/Image.tsx

@ -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);

Loading…
Cancel
Save