【发布时间】:2016-12-04 17:32:03
【问题描述】:
我想将 Material-UI 的 RaisedButton (http://www.material-ui.com/#/components/raised-button) 用作 <input/>,所以我尝试了以下操作:
<RaisedButton
containerElement={<input type="file" onChange={this._handleImageChange}/>}
label="Upload Image"
labelColor='#88898C'
labelStyle={{textTransform:'intial'}}
backgroundColor='#1C1C1F'
/>
但我收到一个错误Invariant Violation: input is a void element tag and must not have "children" or use "props.dangerouslySetInnerHTML". Check the render method。
有没有办法做到这一点?我希望 RaisedButton 的行为类似于 <input type="file" onChange={this._handleImageChange}/>
提前谢谢你!
【问题讨论】:
-
您认为
containerElement应该做什么?我在文档中找不到它。 -
好的,看来
containerElement是包含按钮的元素。将input放在那里是为了什么?您是否尝试使用RaisedButton进行文件上传? -
@DavinTryon 是的,这正是我想做的!
标签: javascript html reactjs redux