0
我想模拟文件输入上的onChange事件,以便能够测试我的upload
函数。我知道如何提交onChange,但我不知道onChange的参数应该是什么。 我知道这可能是一个事件,但我不知道如何创建文件输入事件。 我的反应DOM元素:模拟文件输入onChange
<input className='attachmentInput' style={{ display: 'none' }} ref={(input) => this.attachmentInput = input} type='file' onChange={upload()}/>
我的测试代码:
let file = new File(['some content'], 'filename.txt'
this.subject.find('.attachmentInput').props().onChange(?)
,我需要它进行测试我的onChange功能。 – Ela
https://developer.mozilla.org/zh-CN/docs/Web/Events/change 更改事件非常简单,并且不包含任何有趣的内容。 据我所知,文件信息/内容不是其中的一部分。 –
这可能是你需要的: http://stackoverflow.com/questions/2856513/how-can-i-trigger-an-onchange-event-manually –