| | |
| | | :on-success="handleSuccess" |
| | | :on-error="handleError" |
| | | :list-type="listType" |
| | | :on-preview="handlePreview" |
| | | :on-remove="handleRemove" |
| | | :headers="getToken()"> |
| | | <div class="upload-btn" :style="{'height':btnHeight,'width':btnWidth}"> |
| | |
| | | // 多选 |
| | | multiple: false, |
| | | // 限制 |
| | | limit: 50, |
| | | limit: 4, |
| | | // 按钮高度 |
| | | btnHeight: '120px', |
| | | btnHeight: '100px', |
| | | // 按钮宽度 |
| | | btnWidth: '120px', |
| | | btnWidth: '100px', |
| | | // 文件列表类型 |
| | | listType: 'picture-card' |
| | | }; |
| | |
| | | if (rawFile.type !== 'image/png' && rawFile.type !== 'image/svg+xml' && rawFile.type !== 'image/jpg' && rawFile.type !== 'image/jpeg') { |
| | | this.$message.error('图片必须是 jpg/svg/jpeg/png 格式!') |
| | | return false |
| | | } else if (rawFile.size / 105 / 105 > 2) { |
| | | this.$message.error('上传图片不能超过 2MB!') |
| | | } else if (rawFile.size / 1024 / 1024 > 5) { |
| | | this.$message.error('上传图片不能超过 5MB!') |
| | | return false |
| | | } |
| | | return true |
| | |
| | | }, |
| | | // 移除文件 |
| | | handleRemove(file, fileList){ |
| | | console.log(file,fileList) |
| | | this.$emit('delPictureUrl',{url:file.response.data.url1}); |
| | | } |
| | | }, |
| | | props: { |
| | | // 返回上传成功图片地址 |
| | | setPictureUrl:{ |
| | | type:Function, |
| | | default:()=>{} |
| | | }, |
| | | delPictureUrl:{ |
| | | type:Function, |
| | | default:()=>{} |
| | | } |
| | |
| | | } |
| | | |
| | | :deep(.el-upload--picture-card) { |
| | | width: 120px; |
| | | height: 120px; |
| | | width: 100px; |
| | | height: 100px; |
| | | } |
| | | :deep(.el-upload-list__item){ |
| | | width: 120px; |
| | | height: 120px; |
| | | width: 100px; |
| | | height: 100px; |
| | | } |
| | | .upload-btn { |
| | | // background-color: rgba(249, 249, 249, 1); |