Skip to content

FileUpload ​

EasyFileUpload is a file upload component based on Element Plus Upload component. It simplifies the upload logic, checks file types and sizes, and automatically extracts file links from backend responses.

Online Demo ​

请上传 大小不超过 2MB 格式为 png/jpg/jpeg/pdf 的文件
    绑定值:
    <template>
      <div class="demo-upload">
        <easy-file-upload
          v-model="fileList"
          action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
          :limit="3"
          :file-size="2"
          :file-type="['png', 'jpg', 'jpeg', 'pdf']"
        />
        <div style="margin-top: 20px">绑定值: {{ fileList }}</div>
      </div>
    </template>
    
    <script setup>
    import { ref } from "vue"
    import { EasyFileUpload } from "easy-elplus"
    
    const fileList = ref("")
    </script>
    
    <style scoped>
    .demo-upload {
      width: 100%;
    }
    </style>

    API ​

    Attributes ​

    AttributeDescriptionTypeDefault
    v-modelBinding value, supports comma-separated string, object, or arrayString / Object / Array—
    actionUpload URL (Required)String—
    limitMax upload countNumber5
    file-sizeFile size limit (MB)Number5
    file-typeAllowed file extensionsArray["doc", "xls", "ppt", "txt", "pdf"]
    is-show-tipWhether to show upload tipBooleantrue
    headersRequest headers for uploadObject{}
    base-urlBase URL. Attempts to remove this prefix when saving after successful upload; concatenates this prefix when displaying if not an absolute pathString""
    check-successCustom success check function, accepts response object as parameterFunctionres => res.code === 200 || res.success === true
    response-pathPath to file URL in response, supports deep nesting (e.g. data.url)String"data"
    error-fieldPath to error message in responseString"msg"

    Events ​

    Event NameDescriptionCallback Parameters
    update:modelValueTriggered when binding value changes(value: string)

    Features ​

    1. Auto Extract URL: No need to handle on-success manually, just configure via response-path.
    2. Multiple File Support: Built-in multiple file upload support, controlled via limit.
    3. Format Validation: Automatic extension matching based on file-type.
    4. Path Handling: Conveniently handle image server prefix via base-url.