gpt4 book ai didi

reactjs - 如何在 react 中默认检查单选按钮?

转载 作者:行者123 更新时间:2023-12-03 13:12:54 25 4
gpt4 key购买 nike

如何使单选按钮选中初始值为true?

最佳答案

使用defaultChecked属性(property),可用于 <input type="checkbox"><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" />

关于reactjs - 如何在 react 中默认检查单选按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45072603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com