如何使用reactjs更改文件输入的默认文本?

时间:2020-06-03 13:57:25

标签: html css reactjs input jsx

我在jsx上有一个输入文件,我想更改文本“ Choisir un fichier”和“ Aucun fichier choisi”

我的代码是:

<div className="form-group">
    <label className="control-label col-sm-2" ><strong>Site - Logo (150 x 30px)</strong></label>
    <div className="col-sm-10">
        <input type="file" className="form-control-file" onChange={this.handleImgLogoChange} style={{border:'.1rem solid #d9d9d9', borderRadius:'.2rem'}}/>
    </div>
</div>

运行它,我得到:

enter image description here

如何更改输入文件的默认文本?

1 个答案:

答案 0 :(得分:1)

        <div style={{width: 80, height: 80, border: '1px solid red', position: 'relative'}}>
          <label for='file' style={{position: 'absolute', width: 80, height: 80, cursor: 'pointer'}}>select file</label>
          <input id='file' type='file' onChange={this.handleFileUpload} style={{opacity: 0}} />
        </div> 

也许是这样吗?

您可以在stackblitz demo上查看在线演示