reactjs - 如何使用 react-dropzone 处理 2 个区域
问题描述
我需要在一个组件中使用 2 个不同的 dropzones 来存储 2 个不同的文件和 useDropeZone 版本。我正在尝试使用 onDropAccepted 并使用输入 id 检索事件......但 id 永远不会改变。
我有 2 个这样的 dropezone:
<div {...getRootProps({style})}>
<input id={'new_logo_input'} {...getInputProps()} />
<p>Drop logo (jpg,png)</p>
</div>
<div {...getRootProps({style})}>
<input id={'new_stamp_input'} {...getInputProps()} />
<p>Drop stamp (jpg,png)</p>
</div>
和 useDropeZone 一样:
const { fileRejections, getRootProps, getInputProps, isDragActive, isDragReject, isDragAccept} = useDropzone({
onDropAccepted: (files,event)=>{
console.log(files,event.target.id )
}
})
但是 event.target.id 总是返回'new_stamp_inout'.....!!!
任何人都可以帮助我吗?
非常感谢
解决方案
推荐阅读
- performance - monetdblite 性能跟踪
- angular - Angular 7:如何正确解析后端响应以从字符串中提取日期?
- google-play - Google Play 如何处理我提供的隐私政策链接?
- vue.js - 外部文件中的 VUEX 突变和操作
- javascript - 组合来自多个无线电组的值以显示 div
- android - GoogleSignIn 停止工作 - onActivityResult 中的 responseCode 为 0
- php - 如何从数据库中选择用户的所有条目?
- ios - NFC 标签读取应用程序。线程 1:信号 SIGABRT
- spark-streaming - 如何在 Spark Streaming 中将 DStream[(Array[String], Long)] 转换为数据帧
- python - 根据时间/位置特征快速分组 DataFrame 行