From 9f7df84af0a9d79c883f02020aacb2e7cdfa35c6 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Tue, 3 Jul 2018 10:22:03 +0800 Subject: [PATCH] fix: upload thumbUrl preview not work --- components/upload/Upload.jsx | 6 +-- components/upload/UploadList.jsx | 4 ++ .../__tests__/__snapshots__/demo.test.js.snap | 23 +++--------- components/upload/demo/avatar.md | 37 ++++++++++++------- components/upload/demo/picture-card.md | 10 ++--- components/upload/demo/picture-style.md | 8 ++-- components/upload/interface.jsx | 2 +- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/components/upload/Upload.jsx b/components/upload/Upload.jsx index 1cb8e2d54..7ffcdd393 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 7041bf90b..e858b504e 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 9a4d53791..3555fb6ea 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 93c5e2d85..a4b6a3b54 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 }