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 –