reactjs - How to set TextField to empty string?
问题描述
I want the text field to contain the data, and if column
is null, the textField will be empty as well. This solution works, but it seems ugly as it contains a string. If I use an empty string '' then the label "becomes" the value ( instead of appearing as the label of the textfield, it appears as the value it self, position wise).. What do I need to change ?
<TextField
margin="normal"
fullWidth
inputProps={{
disabled: true
}}
// eslint-disable-next-line
label={labels.accountNumber}
value={props.column || ' '}
/>
解决方案
请添加它将保留上侧的标签。
InputLabelProps={{
shrink: true,
}}
推荐阅读
- scala - 用于 alpakka SQS 的 Scala OpenTracing 库
- python - 如何绘制特定时间戳的昼夜曲线(具有平均值)?
- java - 像 ArrayAdapter 这样的单个项目的 Android 适配器是一个列表吗?
- java - HashSet 是一个写得很好的类吗?
- mongodb - 带有可选字段的 MongoDB 索引
- python - Django中DeleteView的问题
- vb.net - 无法保存新创建的 bmp 文件,需要帮助
- css - css 或 js 调整图像大小以适应容器
- r - 这个流程是提取多边形层内所有像素 > 2 的区域,对吗?
- kustomize - 自定义如何在每个数组中进行目标替换