如何使用 Redux-form 从复选框中获取值? [英] How do I use Redux-form to get values from checkboxes?

查看:42
本文介绍了如何使用 Redux-form 从复选框中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 redux 表单中复选框的默认布尔值更改为您在输入本身上指定的值?

How do you change the default boolean value for a checkbox in redux form to be the value you specify on the input itself?

例如,我有一个这样的输入:

For example, I have an input like this:

<input type="checkbox" value="页面丢失或乱序" {...issue1}/>

当 Redux 表单选择这个时,它只会给我一个真/假,即使我想要值页面丢失或乱序"

When Redux form picks this up, it just gives me a true/false, even though I want the value "Pages missing or out of order"

我可以做这样的事情来到达我需要去的地方,以便当表单提交时,它会提交值页面丢失或乱序,而不是真/假?

Can I do something like this to get where I need to go so that when the form submits, it will submit the value "Pages missing or out of order, instead of true/false?

console.log(value.target.value)} value="页面丢失或乱序"/>

当我删除 {...issue1} 时,将调用我的自定义 onChange 事件处理程序,但是当我保留 {...issue1} 时,它会被完全忽略.

when I remove the {...issue1}, my custom onChange event handler will be called, but when I keep {...issue1}, it's completely ignored.

想法?

推荐答案

不,redux-form 将复选框视为布尔值.您必须将布尔值映射到其他地方的字符串.

No, redux-form treats checkboxes as boolean values. You'll have to map the boolean to the string elsewhere.

这篇关于如何使用 Redux-form 从复选框中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆