说明:
action:必填
auto-upload:el-upload组件自动上传,默认值为true, false为关闭自动上传


/**
     * 手动上传
     */
    upLoad() {
      this.$refs.imageUpload.submit()
    },
<el-upload
          ref="imageUpload"
          :action="crmFileSaveUrl"
          :headers="httpHeader"
          :data="{type: 'img', batchId: batchId}"
          :on-preview="handleFilePreview"
          :before-remove="beforeRemove"
          :on-success="imgFileUploadSuccess"
          :file-list="imgFileList"
          :before-upload="handleBeforeUpload"
          :auto-upload="autoUpload"
          :disabled="isUpload"
          name="file"
          multiple
          accept="image/*"
          list-type="picture-card"
        />
handleBeforeUpload(file) {
      // 限制文件上传大小
      const isLt10M = file.size / 1024 / 1024 < 10
      if (!isLt10M) {
        this.$message.error('上传文件大小不能超过 10MB!')
        return false
      }
    },
Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐