[英]How can I implement increase or decrease quantity till countInStock of my my e-commerce project with the below code?
I have made same thing using form Form.control .我使用表单 Form.control 做了同样的事情。 Here is the code and screenshot这是代码和屏幕截图
{product.countInStock > 0 && (
<ListGroupItem>
<Row>
<Col>Qty</Col>
<Form.Control
as="select"
value={qty}
onChange={(e) => setQty(e.target.value)}
>
{[...Array(product.countInStock).keys()].map((x) => (
<option key={x + 1} value={x + 1}>
{x + 1}
</option>
))}
</Form.Control>
</Row>
</ListGroupItem>
)}
but I want the same thing in input tag format like this但我想要像这样的输入标签格式相同的东西
<input
type="number"
value={qty}
onChange={(e) => setQty(e.target.valueAsNumber)}
min="0"
max={product.countInStock}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.