Skip to content

ImageUpload ​

A secondary encapsulation of the element-plus upload component. It simplifies basic image operations.

Basic Usage ​

INFO

Use the api for asynchronous logic to customize the upload process, then construct the image URL parameter url.

Multiple Image Control ​

Properties ​

Property NameDescriptionTypeExtendedDefault Value
v-modelImage URLstringYes-
apiAsynchronous upload method (required; the built-in fallback returns an empty url and always fails)FunctionYes() => Promise.resolve({ url: '' })
image-typesImage format restrictions (MIME array)ArrayYes['image/webp','image/png','image/jpg','image/gif','image/bmp','image/jpeg']
limit-sizeImage size limit in MBnumberYes10
styleCustom styleRecordYes{ width: '100px', height: '100px' }
fitImage fill modeenumYescontain
multipleEnable multiple image modebooleanYesfalse
limitMaximum number of images in multiple modenumberYes9
disabledDisable the uploadbooleanYesfalse
on-progressHook triggered during file uploadFunctionNo-
on-changeHook triggered when file status changesFunctionNo-

Events ​

Event NameDescriptionTypeExtended
update:model-valueTriggered when the bound value changesFunctionYes
successTriggered on successful uploadFunctionYes
errorTriggered on upload failure; also triggered in multiple mode when the url returned by api is outside the protocol whitelist (http(s)😕/, data:, blob:)FunctionYes
deleteTriggered when an image is deletedFunctionYes

Methods ​

Method NameDescriptionParametersReturn Value
clearFilesClear all images-void
submitManually trigger upload-void
getUploadRefGet el-upload instance-ElUpload instance
getUrlListGet parsed image URL list-string[]

Released under the MIT License