diff --git a/components/upload/Upload.jsx b/components/upload/Upload.jsx index 1cb8e2d545..7ffcdd393c 100644 --- a/components/upload/Upload.jsx +++ b/components/upload/Upload.jsx @@ -13,8 +13,6 @@ import { T, fileToObject, genPercentAdd, getFileItem, removeFileItem } from './u export { UploadProps } -function noop () {} - export default { name: 'AUpload', Dragger: Dragger, @@ -189,9 +187,11 @@ export default { }, on: { remove: this.handleManualRemove, - preview: this.$listeners.preview || noop, }, } + if (this.$listeners.preview) { + uploadListProps.on.preview = this.$listeners.preview + } return (
- - - - - - +
- - - - - - +
-
- -


diff --git a/components/upload/demo/avatar.md b/components/upload/demo/avatar.md index 7041bf90b5..e858b504e2 100644 --- a/components/upload/demo/avatar.md +++ b/components/upload/demo/avatar.md @@ -29,10 +29,10 @@ The return value of function `beforeUpload` can be a Promise to check asynchrono - ``` diff --git a/components/upload/demo/picture-card.md b/components/upload/demo/picture-card.md index 9a4d537912..3555fb6ea3 100644 --- a/components/upload/demo/picture-card.md +++ b/components/upload/demo/picture-card.md @@ -24,7 +24,7 @@ After users upload picture, the thumbnail will be shown in list. The upload butt
- example + example
@@ -43,20 +43,20 @@ export default { } }, methods: { - handleCancel() { + handleCancel () { this.previewVisible = false }, - handlePreview(file) { + handlePreview (file) { this.previewImage = file.url || file.thumbUrl this.previewVisible = true }, - handleChange({ fileList }) { + handleChange ({ fileList }) { this.fileList = fileList }, }, } - diff --git a/components/upload/interface.jsx b/components/upload/interface.jsx index 93c5e2d857..a4b6a3b54d 100755 --- a/components/upload/interface.jsx +++ b/components/upload/interface.jsx @@ -30,7 +30,7 @@ export const UploadFileStatus = PropsTypes.oneOf(['error', 'success', 'done', 'u function UploadFile ({ uid, name }) { if (!uid && uid !== 0) return false if (!['string', 'number'].includes(typeof uid)) return false - if (!name && typeof name !== 'string') return false + if (name === '' || typeof name !== 'string') return false return true }