首页 > 解决方案 > 我的输入应该是一个复选框,但呈现为一个文本输入框

问题描述

我正在尝试使用 CurrencyFormat 在 value 属性中呈现代码,但输入显示为带有文本类型而不是复选框的输入。正在渲染什么

<CurrencyFormat 
                renderText={(value) => (
                    <>
                        <p>
                            Subtotal ({basket?.length} items): <strong> {` ${value}`}</strong>
                        </p>
                        <small className="subtotal__gift">
                            <input type="checkbox"/> This order contains a gift
                        </small>
                    </>
                )}
                decimalScale={2}
                value={0}
                display={"text"}
                thousandSeparator={true}
                prefix={"$"}
   />

标签: htmlreactjs

解决方案


应该:

displayType={"text"}

不是:

display={"text"}

示例:https ://codesandbox.io/s/inspiring-rgb-o2w94?file=/src/App.js:761-790


推荐阅读