【发布时间】:2023-01-08 13:59:26
【问题描述】:
我正在研究 Reactjs,我有带有单选按钮的问题列表(使用循环) 我想在点击的单选按钮上添加课程,但现在无法添加课程, 这是我当前的代码
<FormControlLabel
key={`radio${item.id}${count + 2}`}
value={item.id.toString()}
control={<Radio color="primary" required={item.required} />}
label={getChoice(item)}
onClick={myfunct}
/>
))}
在 jquery 中我使用下面的代码
const myfunct = event => {
$(this).addClass('my-selected-item');
}
【问题讨论】:
-
混合使用 jQuery 和 React 会带来很多麻烦。 React 已经有了处理状态管理和样式的好方法,比如this answer。
标签: javascript reactjs