Skip to content

useFileReader

读取文件内容

演示

示例

vue
<template>
  <
input
ref
="
inputRef
"
type
="file"
style
="display: none"
@
change
="() =>
file
=
inputRef
!.
files
?.[0]"
> <
button
@
click
="
inputRef
!.
click
()">选择文件</
button
>
</template> <script lang="ts" setup> import {
useFileReader
} from '@mixte/use';
import {
ref
} from 'vue';
const
inputRef
=
ref
<HTMLInputElement>();
const
file
=
ref
<File>();
const {
result
,
isReading
,
error
} =
useFileReader
(
file
, 'DataURL');
</script>

Released under the MIT License.