使用 我的应用 也是一种 支持 我的方式:
DockLift: 点击 Dock 应用窗口回到当前屏幕 Zipora: Zip/RAR/7Z 解压工具 Scap: Screenshot & Markup Edit Screen Test Deskmark Keyzer Vidwall Hub VidCrop Vidwall Mousio Hint Mousio Musicer Audioer FileSentinel FocusCursor Videoer KeyClicker DayBar Iconed Menuist Quick RSS Quick RSS Web Serve Copybook Generator DevTutor for SwiftUI RegexMate Time Passage Iconize Folder Textsound Saver Create Custom Symbols DevHub Resume Revise Palette Genius Symbol Scribe

FileInput 上传输入框 === [![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor) [![Telegram Channel](https://img.shields.io/badge/%20-Telegram-00618f.svg?logo=Telegram)](https://t.me/s/AwesomeMacApps) [![Follow On X](https://img.shields.io/badge/Follow%20on%20X-333333?logo=x&logoColor=white)](https://x.com/jaywcjlove) [![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-file-input/file/README.md) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/react-file-input.svg?style=flat)](https://www.npmjs.com/package/@uiw/react-file-input) [![npm version](https://img.shields.io/npm/v/@uiw/react-file-input.svg?label=@uiw/react-file-input)](https://npmjs.com/@uiw/react-file-input) 这个组件仅仅是对 `` 的美化,他是基于 Input 组件封装 。 ```jsx import { FileInput } from 'uiw'; // or import FileInput from '@uiw/react-file-input'; ``` ### 基础用法 ```jsx mdx:preview&bg=#fff import React from 'react'; import { FileInput, Button } from 'uiw'; export default function Demo() { const onChange = (e) => { console.log(e) } return (


) } ``` ### 图片墙 ```jsx mdx:preview&bg=#fff import React from 'react'; import { FileInput, Button, Icon } from 'uiw'; export default function Demo() { return (
console.log(file)} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4'} ]} onChange={(items) => console.log(items)} >
console.log(file)} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4'} ]} onChange={(items) => console.log(items)} >
console.log(file)} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4'} ]} onChange={(items) => console.log(items)} >
) } ``` ### 图片预览 ```jsx mdx:preview&bg=#fff import React from 'react'; import { FileInput, Overlay, Icon } from 'uiw'; export default function Demo() { const [visible,visibleSet]=React.useState(false) const [curfile,curFileSet]=React.useState(null) console.log('curfile',curfile) return( <> visibleSet(false)} > {`${curfile?.name}`} { visibleSet(true) curFileSet(file) }} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' } ]} > ) } ``` ### 图片列表样式 ```jsx mdx:preview&bg=#fff import React from 'react'; import { FileInput, Button } from 'uiw'; export default function Demo() { return (
console.log(234)} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' } ]} >
console.log(234)} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' } ]} >
console.log(234)} value={[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' } ]} >
); } ``` ### 在 `Form` 表单中使用 ```jsx mdx:preview&bg=#fff import React,{ useRef } from 'react'; import { Form, Row, Col, Icon,FileInput,Button } from 'uiw'; export default function Demo() { const form = useRef() return (
{ console.log('current',current) }} fields={{ picture1: { label: '图片墙', initialValue: [ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' } ], children: ( ) }, picture2: { label: '图片列表', initialValue: [ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' } ], children: ( ) }, picture3: { label: '图片名称列表', children: ( ) }, }}> {({ fields, state, canSubmit }) => { return (
{fields.picture1} {fields.picture2} {fields.picture3}
                    {JSON.stringify(state.current, null, 2)}
                  
) }}
) } ``` ## Props - `uploadType: input` 基础输入框上传 - `uploadType: picture` 图片列展示列表,显示图片 - `uploadType: text` 图片列展示列表,不显示图片 - `uploadType: card` 图片墙列表 | 参数 | 说明 | 类型 | 默认值 | |--------- |-------- |--------- |-------- | | uploadType | 上传展示类型 | `input`、`picture`、`text`、`card` | `input` | | className | CSS类名称 | String | - | | multiple | 是否多选上传 | boolean | - | ### Props uploadType input类型 | 参数 | 说明 | 类型 | 默认值 | |--------- |-------- |--------- |-------- | | dataLabel | input 后置文字 | `string` | `Browse` | 更多属性文档请参考 [Input](#/components/input)。 ### Props uploadType 非input类型 | 参数 | 说明 | 类型 | 默认值 | |--------- |-------- |--------- |-------- | | value | 默认图片列表 | FileInputValue[] | - | | readonly | 是否是只读模式 | boolean | false | | maxNumber | 文件上传数量 | boolean | false | | shape | 图片展示形状 | `circle`、`round` | `round` | | size | 图片展示大小 | `large`、`middle`、`small` | `middle` | | showFileIcon | 设置图标按钮是否展示 | {showPreviewIcon?: boolean,showRemoveIcon?: boolean} | {showPreviewIcon: true, showRemoveIcon: true} | | onChange | 文件上传回调 | (value: FileInputValue[]) => void | - | | onPreview | 预览图标时的回调 | (value: FileInputValue[]) => void | - |