elementUI当中的上传图片的组件当中有一个回调函数是 on-success ,这个回调函数只有在使用它的默认的上传方法才会触发,使用自定义的http-request 方法是不会触发 on-success 当中的函数的,所以改成COS上传之后可以直接去掉这个函数。之后的成功回调写在腾讯云COS自带的putObject方法的最后一个参数当中。
<el-upload
multiple
action="#"
:http-request="upload"
list-type="picture-card"
:on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
ref="imageUpload"
:on-remove="handleDelete"
:show-file-list="true"
:headers="headers"
:file-list="fileList"
:on-preview="handlePictureCardPreview"
:class="{hide: this.fileList.length >= this.limit}"
>
<i class="el-icon-plus"></i>
</el-upload>