繁体   English   中英

如何使用以下代码实现我的电子商务项目的 countInStock 数量的增加或减少?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM