fix(Uploader): chooseFile is invalid when show-upload = false (#11221)

This commit is contained in:
Gavin 2022-11-04 15:15:46 +08:00 committed by GitHub
parent 4297aa9888
commit 4db2ca6cd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -404,7 +404,7 @@ export default createComponent({
}, },
genUpload() { genUpload() {
if (this.fileList.length >= this.maxCount || !this.showUpload) { if (this.fileList.length >= this.maxCount) {
return; return;
} }
@ -446,6 +446,7 @@ export default createComponent({
return ( return (
<div <div
v-show={this.showUpload}
class={bem('upload', { readonly: this.readonly })} class={bem('upload', { readonly: this.readonly })}
style={style} style={style}
onClick={this.onClickUpload} onClick={this.onClickUpload}

View File

@ -476,9 +476,11 @@ test('close-preview event', async () => {
test('show-upload prop', () => { test('show-upload prop', () => {
const wrapper = mount(Uploader); const wrapper = mount(Uploader);
expect(wrapper.contains('.van-uploader__upload')).toBeTruthy();
const upload = wrapper.find('.van-uploader__upload');
expect(upload.element).toBeTruthy();
wrapper.setProps({ showUpload: false }); wrapper.setProps({ showUpload: false });
expect(wrapper.contains('.van-uploader__upload')).toBeFalsy(); expect(upload.element.style.display).toBe('none');
}); });
test('file message should be reactive', (done) => { test('file message should be reactive', (done) => {