javascript - react input file
問(wèn)題描述
1 在我的頁(yè)面中有一個(gè)隱藏的input type 類型的file元素,該元素通過(guò)ref屬性可以獲取到,取名為this.inputFile 2 頁(yè)面頭部右邊有一個(gè)按鈕,點(diǎn)擊該按鈕,觸發(fā)該this,fileInput.click()3 但是結(jié)果卻無(wú)法彈出文件選擇框,真是的,這是什么問(wèn)題啊,邏輯沒(méi)問(wèn)題啊 尷尬
class FileManage extends Component{
constructor(props){ super(props); this.onHandleBack = this.onHandleBack.bind(this); this.showOperationSheet = this.showOperationSheet.bind(this);} onHandleBack(){ this.props.history.goBack();}showOperationSheet(){ console.log(’點(diǎn)擊上傳’); if(this.fileInput){console.log(’進(jìn)入判斷’);//很神奇,必須有這行代碼,才能調(diào)用圖片選擇,我也很無(wú)奈啊。console.log(this.fileInput.click());this.fileInput.click() }};render(){ return (<p> <p onClick={this.showOperationSheet}>按鈕</p> <p style={{display:'none'}}><form action='' encType='multipart/form-data' method=’POST’ onSubmit={this._onSubmit}> <input type='file' ref={(input)=>{this.fileInput = input}} onChange={this._onChange}/></form></p></p> )}
}export default FileManage
問(wèn)題解答
回答1:貼具體代碼啊,這樣好難腦補(bǔ)
相關(guān)文章:
1. 如何設(shè)置一個(gè)無(wú)限循環(huán)并打破它。(Java線程)2. 網(wǎng)頁(yè)爬蟲 - 如何使用使用java抓取信息并制作一個(gè)排名系統(tǒng)?3. mysql - 在log日志中已知用戶的某一步操作,如何獲取其上一步操作?4. php對(duì)mysql提取數(shù)據(jù)那種速度更快5. shell - mysql更新錯(cuò)誤6. javascript - sublime快鍵鍵問(wèn)題7. javascript - immutable配合react提升性能?8. python小白 自學(xué)看書遇到看不懂的地方9. macos - 如何徹底刪除mac自帶的apache和php10. DADB.class.php文件的代碼怎么寫

網(wǎng)公網(wǎng)安備