我正在使用antd上传文件,我正在尝试将capture="environment"
添加到我的代码中,就像这个代码<input type="file" accept="image/*" capture="filesystem">
一样。该代码仅适用于在移动设备中访问时打开的相机。如何在antd Upload中实现它?这是我的代码
<Upload
name="avatar"
listType="picture-card"
className="avatar-uploader"
showUploadList={false}
accept="image/x-png,image/jpeg"
>
Antd Upload看起来像是将捕获道具传递给rc Upload(https://github.com/ant-design/ant-design/blob/dc4d85583fe6b12c5a3d8b1a1c9de0589752fc3e/components/upload/Upload.tsx#L380),但是rc上传(antd在这里依赖它(最近才添加了对它的支持。https://github.com/react-component/upload/pull/303
AntD需要更新依赖项,但看起来他们已经在master
中完成了,所以可能需要等待一段时间,然后更新到最新的AntD,否则将派生组件并将更新的依赖项包含在您自己的package.json中。
<Upload
name="avatar"
listType="picture-card"
className="avatar-uploader"
showUploadList={false}
accept="image/x-png,image/jpeg"
capture="environment"
>