[英]How can I implement increase or decrease quantity till countInStock of my my e-commerce project with the below code?
我使用表單 Form.control 做了同樣的事情。 這是代碼和屏幕截圖
{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>
)}
但我想要像這樣的輸入標簽格式相同的東西
<input
type="number"
value={qty}
onChange={(e) => setQty(e.target.valueAsNumber)}
min="0"
max={product.countInStock}
/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.