我怎样才能让“其他”变成一个按钮,用户可以在其中输入尽可能多的钱?

问题描述

我怎样才能让“其他”变成一个按钮,让用户可以输入任意数量的钱?我尝试用一​​个按钮创建一个 const other 并将 {other} 放在选项选项卡中,就像这样 options={['$5','$10','$20','$50','$100',{other}]} 但是那没有用。我正在使用 grommet UI,任何建议表示赞赏。谢谢。

           <RadioButtonGroup direction="row" required
           gap="xlarge"
           id="example2-id"
           name="example2"
           options={['$5','other']}
           />

解决方法

Radiobuttons 返回一个预设值,如果您想允许用户输入自定义值,我建议在您的 Radiobutton 下添加一个 TextInput 并将其包装在一个表单中。