ReactJS Material-UI:在 TextField 中只接受无符号正整数值

新手上路,请多包涵

我有以下输入字段,我希望它只接受正整数,而不可能插入字符 - + , .

 <TextField
  fullWidth
  type="number"
  placeholder={'[1-100]'}
  id="simple-start-adornmhent"
  onChange={this.handleChangeField('amount')}
  InputProps={{ inputProps: { min: 1 } }}
/>

你能给我一些建议吗?

原文由 Paul 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 453
1 个回答

尝试这个

  <TextField  type="number"
     label="Short stop treshold"
     InputProps={{
        inputProps: { min: 0 }
      }}
     value={10}
     onChange={handleShortStopChange} />

原文由 Shahnad S 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题