例如,我有2个大小的小和中等。我如何才能保存两个数据加在一起成为一个新的totalCount数据或任何最佳做法的代码下面的代码,请
const [sizeSmall, setSizeSmall] = useState(0)
const [sizeMed, setSizeMed] = useState(0)
const [totalCount, setTotalCount] = useState(0) // This will be sizeSmall + sizeMed add together
**// How can I make the total of both sizes into one total
<input
type=number
value = {sizeSmall}
onChange = (e => setSizeSmall(e.target.value)
required
/>
<input
type=number
value = {sizeMed}
onChange = (e => sizeMed(e.target.value)
required
/>
1条答案
按热度按时间u3r8eeie1#
现在起作用了