ReactJs 如何 increment/decrement 小数点右边的数字
ReactJs how to increment/decrement numbers right of decimal
我正在使用 React JS。基本上,我有一个输入字段,在输入字段的右侧有递增和递减按钮。当我递增该字段时,小数点右侧的数字会递增,而不是左侧的数字。不知道该怎么做,因为其他人似乎没有问这个问题。或者行为很奇怪。请看下面的代码和图片。谢谢!
输入组件:
<FormLabel component="legend" style={{ marginBottom: '8px' }}>
Hide Balances Below
</FormLabel>
<FormControl>
<Input
name="amount"
type="number"
inputProps={{ step: 'any' }}
value={dustThreshold}
onChange={e => setDustThreshold(e.target.value)}
endAdornment={
<InputAdornment position="end">
{ellipsize('BTC', this.ELLIPSE_LENGTH)}
</InputAdornment>
}
className={classes.input}
disableUnderline
/>
</FormControl>
基本上是尝试让右侧 (.00001666) 的值递增和递减,而不是在“30”所在的位置(小数点左侧)
这不是反应问题,你只需要添加特定小数位的步骤。 step=".00000001"
<input
name="amount"
type="number"
step=".00000001"
value="30.00001666"/>
我正在使用 React JS。基本上,我有一个输入字段,在输入字段的右侧有递增和递减按钮。当我递增该字段时,小数点右侧的数字会递增,而不是左侧的数字。不知道该怎么做,因为其他人似乎没有问这个问题。或者行为很奇怪。请看下面的代码和图片。谢谢!
输入组件:
<FormLabel component="legend" style={{ marginBottom: '8px' }}>
Hide Balances Below
</FormLabel>
<FormControl>
<Input
name="amount"
type="number"
inputProps={{ step: 'any' }}
value={dustThreshold}
onChange={e => setDustThreshold(e.target.value)}
endAdornment={
<InputAdornment position="end">
{ellipsize('BTC', this.ELLIPSE_LENGTH)}
</InputAdornment>
}
className={classes.input}
disableUnderline
/>
</FormControl>
基本上是尝试让右侧 (.00001666) 的值递增和递减,而不是在“30”所在的位置(小数点左侧)
这不是反应问题,你只需要添加特定小数位的步骤。 step=".00000001"
<input
name="amount"
type="number"
step=".00000001"
value="30.00001666"/>