From 66c0b3c1b7d101f242071cf90e5c0b2b899edbdd Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 15 Mar 2020 11:00:45 +0800 Subject: [PATCH] feat(Uploader): add show-upload prop --- src/uploader/README.md | 1 + src/uploader/README.zh-CN.md | 1 + src/uploader/index.js | 6 +++++- src/uploader/test/index.spec.js | 7 +++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/uploader/README.md b/src/uploader/README.md index a89d3a3c9..0bed95ecf 100644 --- a/src/uploader/README.md +++ b/src/uploader/README.md @@ -165,6 +165,7 @@ export default { | multiple | Whether to enable multiple selection pictures | *boolean* | `false` | | disabled | Whether to disabled the upload | *boolean* | `false` | | deletable `v2.2.12` | Whether to show delete icon | *boolean* | `true` | +| show-upload `v2.5.6` | Whether to show upload area | *boolean* | `true` | | capture | Capture,can be set to `camera` | *string* | - | | after-read | Hook after reading the file | *Function* | - | | before-read | Hook before reading the file, return false to stop reading the file, can return Promise | *Function* | - | diff --git a/src/uploader/README.zh-CN.md b/src/uploader/README.zh-CN.md index 2f6e78453..069124b76 100644 --- a/src/uploader/README.zh-CN.md +++ b/src/uploader/README.zh-CN.md @@ -186,6 +186,7 @@ export default { | multiple | 是否开启图片多选,部分安卓机型不支持 | *boolean* | `false` | | disabled | 是否禁用文件上传 | *boolean* | `false` | | deletable `v2.2.12` | 是否展示删除按钮 | *boolean* | `true` | +| show-upload `v2.5.6` | 是否展示上传区域 | *boolean* | `true` | | capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - | | after-read | 文件读取完成后的回调函数 | *Function* | - | | before-read | 文件读取前的回调函数,返回`false`可终止文件读取,
支持返回`Promise` | *Function* | - | diff --git a/src/uploader/index.js b/src/uploader/index.js index 5a8bdfdf7..61efd07f7 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -53,6 +53,10 @@ export default createComponent({ type: Boolean, default: true, }, + showUpload: { + type: Boolean, + default: true, + }, previewImage: { type: Boolean, default: true, @@ -326,7 +330,7 @@ export default createComponent({ }, genUpload() { - if (this.fileList.length >= this.maxCount) { + if (this.fileList.length >= this.maxCount || !this.showUpload) { return; } diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index c52314892..db00cfd8f 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -454,3 +454,10 @@ it('close-preview event', async () => { await later(300); expect(wrapper.emitted('close-preview')).toBeTruthy(); }); + +it('show-upload prop', () => { + const wrapper = mount(Uploader); + expect(wrapper.contains('.van-uploader__upload')).toBeTruthy(); + wrapper.setProps({ showUpload: false }); + expect(wrapper.contains('.van-uploader__upload')).toBeFalsy(); +});