国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

javascript - react input file

瀏覽:161日期:2023-03-27 18:21:07

問題描述

1 在我的頁面中有一個隱藏的input type 類型的file元素,該元素通過ref屬性可以獲取到,取名為this.inputFile 2 頁面頭部右邊有一個按鈕,點擊該按鈕,觸發該this,fileInput.click()3 但是結果卻無法彈出文件選擇框,真是的,這是什么問題啊,邏輯沒問題啊 尷尬

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(’點擊上傳’); if(this.fileInput){console.log(’進入判斷’);//很神奇,必須有這行代碼,才能調用圖片選擇,我也很無奈啊。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

問題解答

回答1:

貼具體代碼啊,這樣好難腦補

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 平武县| 六枝特区| 浪卡子县| 文安县| 乌拉特前旗| 清镇市| 韶山市| 衡阳市| 枣阳市| 沅陵县| 临颍县| 独山县| 夏津县| 宝应县| 虎林市| 奈曼旗| 正定县| 喀喇| 长沙市| 东台市| 正定县| 和林格尔县| 五华县| 读书| 武宣县| 博客| 四川省| 澄江县| 吉安市| 疏附县| 九龙城区| 望谟县| 蛟河市| 辽宁省| 黔东| 清远市| 乃东县| 漯河市| 宽城| 通许县| 鹿邑县|