feat(Uploader): add show-upload prop

This commit is contained in:
chenjiahan 2020-03-15 11:00:45 +08:00
parent ad9d8a7649
commit 66c0b3c1b7
4 changed files with 14 additions and 1 deletions

View File

@ -165,6 +165,7 @@ export default {
| multiple | Whether to enable multiple selection pictures | *boolean* | `false` | | multiple | Whether to enable multiple selection pictures | *boolean* | `false` |
| disabled | Whether to disabled the upload | *boolean* | `false` | | disabled | Whether to disabled the upload | *boolean* | `false` |
| deletable `v2.2.12` | Whether to show delete icon | *boolean* | `true` | | deletable `v2.2.12` | Whether to show delete icon | *boolean* | `true` |
| show-upload `v2.5.6` | Whether to show upload area | *boolean* | `true` |
| capture | Capturecan be set to `camera` | *string* | - | | capture | Capturecan be set to `camera` | *string* | - |
| after-read | Hook after reading the file | *Function* | - | | 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* | - | | before-read | Hook before reading the file, return false to stop reading the file, can return Promise | *Function* | - |

View File

@ -186,6 +186,7 @@ export default {
| multiple | 是否开启图片多选,部分安卓机型不支持 | *boolean* | `false` | | multiple | 是否开启图片多选,部分安卓机型不支持 | *boolean* | `false` |
| disabled | 是否禁用文件上传 | *boolean* | `false` | | disabled | 是否禁用文件上传 | *boolean* | `false` |
| deletable `v2.2.12` | 是否展示删除按钮 | *boolean* | `true` | | deletable `v2.2.12` | 是否展示删除按钮 | *boolean* | `true` |
| show-upload `v2.5.6` | 是否展示上传区域 | *boolean* | `true` |
| capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - | | capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - |
| after-read | 文件读取完成后的回调函数 | *Function* | - | | after-read | 文件读取完成后的回调函数 | *Function* | - |
| before-read | 文件读取前的回调函数,返回`false`可终止文件读取,<br>支持返回`Promise` | *Function* | - | | before-read | 文件读取前的回调函数,返回`false`可终止文件读取,<br>支持返回`Promise` | *Function* | - |

View File

@ -53,6 +53,10 @@ export default createComponent({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
showUpload: {
type: Boolean,
default: true,
},
previewImage: { previewImage: {
type: Boolean, type: Boolean,
default: true, default: true,
@ -326,7 +330,7 @@ export default createComponent({
}, },
genUpload() { genUpload() {
if (this.fileList.length >= this.maxCount) { if (this.fileList.length >= this.maxCount || !this.showUpload) {
return; return;
} }

View File

@ -454,3 +454,10 @@ it('close-preview event', async () => {
await later(300); await later(300);
expect(wrapper.emitted('close-preview')).toBeTruthy(); 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();
});