我正在使用react drop-zone组件将文件上传到服务器。
我想在单击按钮时调用拖放区打开函数。
这是我迄今为止尝试过的:
我正在使用refs
来引用拖放区域。另请注意,我有多个拖放区
<DropzoneComponent
style={{ height: 80 }}
ref={this.myRef}
config={config}
eventHandlers={eventHandlers}
djsConfig={djsConfig}
/>
然后在单独的按钮上单击“我正在调用函数”
openDropZone1 = () => {
this.refs.myRef.open();
this.setState({
bankStatement1: true,
bankStatement2: false,
bankStatement3: false
});
};
单击按钮时出现以下错误:-
TypeError: Cannot read property 'open' of undefined on this line
this.refs.myRef.open();
非常感谢任何帮助或建议。
谢谢。
最佳答案
https://github.com/react-dropzone/react-dropzone/tree/master/examples/file-dialog
这是最终答案,因为它在文档中,如果这不能解决您的问题,则说明您的代码有问题
关于javascript - 如何使用refs触发react-dropzone-component的打开功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52494204/