1.先看看樣式:web
<el-upload
class="imgList"
action="1165165"
list-type="picture-card"
:limit="20"
:file-list="explainImgList"
:on-remove="handleRemove"
:on-exceed="handleExceed" //超過上傳數量時觸發
:http-request="uploadImgList">
<i class="el-icon-plus" style="position: relative;bottom: 27px;"></i>
</el-upload>
2.照片回顯時參數要對應上才行(這裏官方文檔沒說明,有點坑),以下
uploadImgList(item) {
/* 上傳帳號說明圖 */
let formData = new FormData()
formData.append('file', item.file)
UploadFile('/web/account/upload.json', formData).then(res => {
this.explainImgList.push({
'name': item.file.name,
'uid': item.file.uid,
'url': res.fileKey
})
Message.success('上傳成功')
}).catch(err => {
console.log(err)
Message.error('上傳失敗')
})
}
handleRemove(file, fileList) {
/* 移除圖片 */
this.explainImgList = fileList
}
3.樣式也能夠強制改爲咱們想要的
<style> .imgList .el-upload--picture-card { width: 82px; height: 82px; } .imgList .el-upload-list--picture-card .el-upload-list__item { width: 82px; height: 82px; } .imgList .el-upload-list--picture-card .el-upload-list__item-thumbnail { width: 82px; height: 82px; }</style>