本文介绍了如何在反应中对单选按钮进行默认检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让单选按钮检查初始值是否为真?
How to make the radio button checked if the initial value is true?
推荐答案
使用 defaultChecked
属性,可用于 和 <input type="radio"> - https://reactjs.org/docs/uncontrolled-components.html#default-values
Using the defaultChecked
property, available for <input type="checkbox">
and <input type="radio">
- https://reactjs.org/docs/uncontrolled-components.html#default-values
<input type="radio" name="radio-group" value="1" defaultChecked />
<input type="radio" name="radio-group" value="2" />
<input type="radio" name="radio-group" value="3" />
这篇关于如何在反应中对单选按钮进行默认检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!