react 怎么设置默认选中第一个

2025-05-05 09:04:12
推荐回答(1个)
回答1:

你好! 用了checked就要加上一个onChange事件,来改变checked=true or false
The defaultValue and defaultChecked props are only used during initial render. If you need to update the value in a subsequent render, you will need to use a controlled component.
所以如果有值是会变的 只能用checked。 不能用defaultChecked、谢谢!