简体   繁体   English

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

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

相关问题 如何为我的电子商务项目乘以 reactjs? - How do I multiply for my e-commerce project with reactjs? 如何在电子商务表格上要求最低数量? - How Can I require a Minimum Quantity on an e-commerce Form? 如何分别增加和减少数量? - How can I increase and decrease the quantity seperately? 单击电子商务网站中的搜索按钮后,如何阻止页面重新加载? - How can I stop the page from reloading after I click on search button in my E-commerce site? 如何在我的 React Hooks 电子商务应用程序中使用 JSON 文件作为虚拟用户的数据库? - How do I use a JSON file as a database for dummy users in my React Hooks e-commerce app? 如何增加或减少特定商品的数量? - How can I increase or decrease the quantity of a specific item? 如何在增加或减少购物车数量的同时添加移除项目并增加数量并增加价格。 电话代码 - How can I add remove items and increment the quantity and increase the price while incrementing or decrementing the quantity of my cart. code by telmo Google 分析如何跟踪电子商务访问者的行为 - How Google analytics can track e-commerce visitors behavior 如何减少和改进丑陋的JavaScript代码? - How I can decrease and make better my ugly JavaScript code? 如何为我的项目实现这个加载器? - How can I implement this loader for my project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM