【问题标题】:Keep a label tag with date material ui保留带有日期材料 ui 的标签标签
【发布时间】:2021-09-01 00:18:28
【问题描述】:

如果没有设置默认值,如何保持像T.M.T SKEP这样的标签位置?我正在使用材质 UI。

import TextField from '@material-ui/core/TextField';

<TextField
  fullWidth
  label="T.M.T"
  id="tmt"
  name="tmt"
  type="date"
  value=""
  variant="outlined"
 />

【问题讨论】:

    标签: css reactjs jsx


    【解决方案1】:

    在 TextField 中添加此属性。

     InputLabelProps={{
              shrink: true
            }}
    

     <TextField
            fullWidth
            label="T.M.T"
            id="tmt"
            name="tmt"
            type="date"
            value=""
            variant="outlined"
            InputLabelProps={{
              shrink: true
            }}
          />
    

    https://codesandbox.io/s/material-demo-forked-swew3?file=/demo.js

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-02
      • 1970-01-01
      • 2021-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多