Skip to content

Image

Used to show and preview pictures.

Basic

When you need to view a picture, simply set the src property to get a component with preview picture function.

Show caption

By setting title and description, the title and description of the picture can be displayed inside or at the bottom of the picture, and the display position is controlled by footerPosition.

Extra operations

The component provides a named slot extra for users to customize additional content in the footer.

Error state

Content displayed when the image fails to load.

Loading

By default, the loading effect is not displayed, and the default loading effect can be displayed by setting showLoader to true. If the default loading effect does not meet the requirements, you can also set the loading style yourself through the named slot loader.

Progressive loading

When you need to display a large image, you can pass a smaller image to loader to display it when the original image is not successfully loaded to simulate progressive loading.

Preview action bar

The function buttons on the control preview control bar can be sorted and filtered through actionLayout.In addition, the preview component preview provides the actions slot to support custom additional action items, and also provides the action item component

Multi-image preview

Use <preview-group> to wrap the <image> component to preview multiple images.

Use preview alone

preview can be used alone, you need to control visible.

Use PreviewGroup alone

<preview-group> can be used alone, you need to control visible by yourself. The image display is divided into two scenes: First, the first image to be displayed can be specified by defaultCurrent. Second, to control which image is currently displayed by current.

You can specify the parent node of the preview mounted by popupContainer.

Image API

Image Attributes

NameDescriptionTypeDefault
srcImage srcString-
widthImage widthString Number-
heightImage heightString Number-
titleTitleString-
descriptionDescription, will be displayed at the bottom. if alt has no value, it will be set to altString-
fitIndicate how the image should be resized to fit its containerString-
altText description of the imageString-
hide-footerWhether to hide footerBoolean Stringfalse
footer-positionThe position shown at the bottomStringinner
show-loaderWhether to show the loading effectBooleanfalse
previewWhether to enable previewBooleantrue
preview-visible (v-model)Control the open state of the preview, can be used in conjunction with previewVisibleChangeBoolean-
default-preview-visibleThe default open state of the previewBooleanfalse
preview-propsPreview configuration items (all options are optional) ImagePreviewPropsImagePreviewProps-
footer-classThe class name of the bottom display areaString Array Object-

Image Events

NameDescriptionType
preview-visible-changePreview opening and closing eventsFunction

Image Slots

NameDescription
errorCustomize error content.
error-iconCustomize the icon of error content.
loaderCustomize loading effect.
extraExtra content at the bottom

Preview Attributes

NameDescriptionTypeDefault
srcImage srcString-
visible (v-model)Whether is visibleBoolean-
default-visibleDefault visibilityBooleanfalse
mask-closableWhether to close the modal when mask is clickedBooleantrue
closableWhether to show close buttonBooleantrue
actions-layoutLayout of action listArray[ 'fullScreen', 'rotateRight', 'rotateLeft', 'zoomIn', 'zoomOut', 'originalSize']
popup-containerSet the mount point of the pop-up box, the same as the to of teleport, the default value is document.bodyHTMLElement String-
esc-to-closeWhether to support the ESC key to close the previewBooleantrue
wheel-zoomWhether to enable wheel zoomBooleantrue
keyboardWhether to enable keyboard shortcutsBooleantrue
default-scaleDefault scaleNumber1
zoom-rateZoom rate, only for scroll zoomNumber1.1

Preview Events

NameDescriptionType
closeClose event-

Preview Slots

NameDescription
actionsCustomize additional action items

Preview Group Attributes

NameDescriptionTypeDefault
src-listPicture list (after setting this property, the picture information of a-image subcomponent will no longer be collected)Array-
current (v-model)The index of the currently displayed imageNumber-
default-currentThe index of the first image shownNumber0
infiniteWhether to loop infinitelyBooleanfalse
visible (v-model)Whether is visibleBoolean-
default-visibleDefault visibilityBooleanfalse
mask-closableWhether to close the modal when mask is clickedBooleantrue
closableWhether to show close buttonBooleantrue
actions-layoutLayout of action listArray[ 'fullScreen', 'rotateRight', 'rotateLeft', 'zoomIn', 'zoomOut', 'originalSize']
popup-containerSet the mount point of the pop-up box, the same as the to of teleport, the default value is document.bodyHTMLElement String-

Preview Group Events

NameDescriptionType
changeImage switch-
visible-changePreview visibility change-

Preview Group Slots

NameDescription
actionsCustomize additional action items

Preview Action Attributes

NameDescriptionTypeDefault
nameThe name of the actionString-
disabledWhether to disable the actionBooleanfalse

FAQ

Property Description for preview

1.Keyboard Shortcuts - keyboard Setting this property to true enables corresponding keyboard shortcuts based on the actions-layout settings.

  • esc:close preview
  • left: switch to the previous image
  • right: switch to the next image
  • up: zoom in on the image
  • down: zoom out on the image
  • space: restore to original size

2.Default Scaling - defaultScale This property defines the default scaling factor for images. For instance, when set to 1.5, images will be enlarged by 1.5 times their original size by default.

3.Scroll Zoom Rate - zoomSate The zoomSate property controls the scaling rate of images during scrolling. Taking 1.3 as an example, each scrolling action will result in an image zoom-in or zoom-out by a factor of 1.3.