| | |
| | | <div class="my-upload"> |
| | | <el-upload |
| | | :file-list="fileList" |
| | | class="upload-demo" |
| | | action="/sccg/file/medias" |
| | | :multiple="multiple" |
| | | :show-file-list="flag" |
| | |
| | | :list-type="listType" |
| | | :on-remove="handleRemove" |
| | | :headers="getToken()"> |
| | | <div class="upload-btn" :style="{'height':btnHeight,'width':btnWidth}"> |
| | | <div class="upload-btn"> |
| | | <i class="el-icon-plus"></i> |
| | | <span>上传图片</span> |
| | | </div> |
| | |
| | | multiple: false, |
| | | // 限制 |
| | | limit: 4, |
| | | // 按钮高度 |
| | | btnHeight: '100px', |
| | | // 按钮宽度 |
| | | btnWidth: '100px', |
| | | // 文件列表类型 |
| | | listType: 'picture-card' |
| | | }; |
| | |
| | | }, |
| | | // 上传失败回调 |
| | | handleError(err, file, fileList) { |
| | | console.log(err); |
| | | this.$message({ |
| | | type:'error', |
| | | message:err |
| | |
| | | if (token && tokenHead) { |
| | | return { Authorization: tokenHead + token } |
| | | } |
| | | }, |
| | | // 预览 |
| | | handlePreview(file){ |
| | | console.log(file) |
| | | }, |
| | | // 移除文件 |
| | | handleRemove(file, fileList){ |
| | |
| | | delPictureUrl:{ |
| | | type:Function, |
| | | default:()=>{} |
| | | }, |
| | | pictureList: { |
| | | type: Array, |
| | | default: () => [] |
| | | } |
| | | } |
| | | }, |
| | | } |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .my-upload { |
| | | .upload-demo { |
| | | display: flex; |
| | | } |
| | | |
| | | :deep(.el-upload--picture-card) { |
| | | width: 100px; |
| | |
| | | width: 100px; |
| | | height: 100px; |
| | | } |
| | | //.file-list { |
| | | // display: flex; |
| | | // flex-wrap: nowrap; |
| | | //} |
| | | .upload-btn { |
| | | // background-color: rgba(249, 249, 249, 1); |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | border-radius: 4px; |
| | | width: 100px; |
| | | height: 100px; |
| | | |
| | | &:hover i{ |
| | | color: #409eff; |
| | |
| | | line-height: 22px; |
| | | } |
| | | } |
| | | .uploaded-image { |
| | | width: 0; |
| | | height: 100px; |
| | | display: flex; |
| | | } |
| | | } |
| | | </style> |