diff --git a/packages/vant/src/image-preview/ImagePreviewItem.tsx b/packages/vant/src/image-preview/ImagePreviewItem.tsx index 8a34f28ec..229cca488 100644 --- a/packages/vant/src/image-preview/ImagePreviewItem.tsx +++ b/packages/vant/src/image-preview/ImagePreviewItem.tsx @@ -407,7 +407,11 @@ export default defineComponent({ > {slots.image ? (
- {slots.image({ src: props.src })} + {slots.image({ + src: props.src, + onLoad, + style: imageStyle.value, + })}
) : ( { expect(wrapper.html().includes('video')).toBeTruthy(); }); +test('should render image slot correctly 3', async () => { + const wrapper = mount(ImagePreview, { + props: { + show: true, + images, + }, + slots: { + image: ({ src, style }) => + ``, + }, + }); + + await later(); + + expect(wrapper.html().includes('width: 100px')).toBeTruthy(); +}); + test('should emit long-press event after long press', async () => { const onLongPress = vi.fn(); const wrapper = mount(ImagePreview, {