【发布时间】:2020-03-07 01:14:18
【问题描述】:
我正在使用功能组件创建自定义无线电组件。我让道具工作并且css工作但我看不到实际的“单选按钮”。
请查看我的代码 - 我在这里缺少什么。
type Props = {
children: any,
color?: string,
size?: string,
}
const Radio = (props:Props) => {
let radioClass = ''
if(props.size === 'small') radioClass = 'radio-small';
if(props.size === 'large') radioClass = 'radio-large';
if(props.color === 'secondary') radioClass += ' radio-secondary';
if(props.color === 'warning') radioClass += ' radio-warning';
if(props.color === 'light') radioClass += ' radio-light';
if(props.color === 'dark') radioClass += ' radio-dark';
return (
<radio className={radioClass} > {props.children}</radio>
);
};
export default Radio
.radio-small {
font-size: 1.5em;
}
.radio-warning {
color: red;
}
【问题讨论】:
标签: javascript reactjs radio-button radio-group