mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
feat(Uploader): add file result-type (#4680)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
export type ResultType = 'dataUrl' | 'text' | 'file';
|
||||
|
||||
export function toArray<T>(item: T | T[]): T[] {
|
||||
if (Array.isArray(item)) {
|
||||
return item;
|
||||
@@ -6,8 +8,13 @@ export function toArray<T>(item: T | T[]): T[] {
|
||||
return [item];
|
||||
}
|
||||
|
||||
export function readFile(file: File, resultType: string) {
|
||||
export function readFile(file: File, resultType: ResultType) {
|
||||
return new Promise(resolve => {
|
||||
if (resultType === 'file') {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = event => {
|
||||
|
Reference in New Issue
Block a user