我想使用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”的值将是包含您的按钮的元素(换句话说,按钮的父级或包装器)。HTML输入不允许包含任何其他元素,因此会出现错误。
将您输入的内容作为按钮的子项:
<RaisedButton label="Upload Image"
labelColor='#88898C'
labelStyle={{textTransform:'intial'}}
backgroundColor='#1C1C1F'>
<input type="file" onChange={this._handleImageChange}/>
</RaisedButton>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句