feat(Uploader): add chooseFile method (#5818)

This commit is contained in:
Pingren Nie 2020-03-16 09:39:42 +08:00 committed by GitHub
parent 4695dc29b9
commit f5e79dabb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View File

@ -214,3 +214,4 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Uploader instance and call insta
| Name | Description | Attribute | Return value | | Name | Description | Attribute | Return value |
|------|------|------|------| |------|------|------|------|
| closeImagePreview | Close full screen image preview | - | - | | closeImagePreview | Close full screen image preview | - | - |
| chooseFile | Trigger choosing files, works with the user action context only because of browser security | - | - |

View File

@ -239,3 +239,4 @@ before-read、after-read、before-delete 执行时会传递以下回调参数:
| 方法名 | 说明 | 参数 | 返回值 | | 方法名 | 说明 | 参数 | 返回值 |
|------|------|------|------| |------|------|------|------|
| closeImagePreview | 关闭全屏的图片预览 | - | - | | closeImagePreview | 关闭全屏的图片预览 | - | - |
| chooseFile | 主动调起文件选择,由于浏览器安全限制,只有在用户触发操作的上下文中调用才有效 | - | - |

View File

@ -247,6 +247,17 @@ export default createComponent({
} }
}, },
// @exposed-api
chooseFile() {
if (this.disabled) {
return;
}
/* istanbul ignore else */
if (this.$refs.input) {
this.$refs.input.click();
}
},
genPreviewMask(item) { genPreviewMask(item) {
const { status } = item; const { status } = item;

2
types/uploader.d.ts vendored
View File

@ -2,4 +2,6 @@ import { VanComponent } from './component';
export class Uploader extends VanComponent { export class Uploader extends VanComponent {
closeImagePreview(): void; closeImagePreview(): void;
chooseFile(): void;
} }