Skip to content

Commit

Permalink
fix(chooseFile): 返回结果为只读数组
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Nov 25, 2020
1 parent 244cdc6 commit d0fbac2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/chooseFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bindEvent } from './bindEvent'
import { LiteralUnion } from '../types'
import { toArray } from 'lodash-uni'

/**
* 选择文件。
Expand All @@ -11,7 +12,7 @@ import { LiteralUnion } from '../types'
export function chooseFile(
accept: LiteralUnion<'image', string>,
multiple = false,
): Promise<FileList> {
): Promise<ReadonlyArray<File>> {
return new Promise(resolve => {
let input = document.createElement('input')
input.style.all = 'unset'
Expand All @@ -33,7 +34,7 @@ export function chooseFile(
unbindChange()
document.body.removeChild(input)
input = null as any
resolve(files)
resolve(Object.freeze(toArray(files)))
})
input.click()
})
Expand Down

0 comments on commit d0fbac2

Please sign in to comment.