我有 Material-UI TextField:
<TextField id="gen_ref_num" className="col-6 form-control-sm" label="Number" variant="filled" value={this.props.invoice.gen_ref_num} onChange={this.handleChange}/>
并且 this.props.invoice.gen_ref_num
已预加载该值。不幸的是,标签与内容重叠。当我开始编辑字段时,标签向上移动并位于正确的位置(不再重叠)。如何要求 Material-UI TextField 尊重预加载的值并将标签向上移动?
最佳答案
下面的代码就是答案:
InputLabelProps={{ shrink: !!this.state.value }}
当适应问题中的代码时,代码ir:
InputLabelProps={{ shrink: !!this.props.invoice.gen_ref_num }}
有关此内容的更多内容,请访问 https://github.com/mui-org/material-ui/issues/13013
关于reactjs - 具有预加载值的 React Material-UI TextField 不会移动标签(标签与 TextField 内容重叠),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67784970/