我正在使用Semantic-ui-React library尝试创建Radio复选框,这些复选框是必需的。单选按钮该怎么做?在Semantic-ui-React中有什么方法需要下拉菜单吗?
import React, { Component } from 'react'
import { Divider,Label,List,Checkbox,Header } from 'semantic-ui-react'
handleRequest = (e, { value, label }) => {
this.setState({
redirect: false,
requestCategory: value,
typeOfRequest: label
});
}
<Form.Field>
<Form.Field>
<Checkbox className = 'radio'
required
label="New Solution"
name="typeOfRequest"
value={false}
checked={requestCategory === 'false'}
onChange={this.handleRequest}
/>
</Form.Field>
<Form.Field>
<Checkbox className = 'radio'
required
label="Enhancement to Existing Solution"
name="typeOfRequest"
value={'all'}
checked={requestCategory === 'all'}
onChange={this.handleRequest}
/>
</Form.Field>
<Form.Field>
<Checkbox className = 'radio'
required
label="Production Support"
name="typeOfRequest"
value={'all'}
checked={requestCategory === 'false'}
onChange={this.handleRequest}
/>
</Form.Field>
<Form.Field>
<Checkbox className = 'radio'
required
label="New Analysis"
name="typeOfRequest"
value={'all'}
checked={requestCategory === 'all'}
onChange={this.handleRequest}
/>
</Form.Field>
<Form.Field>
<Checkbox className = 'radio'
required
label="Existing Analysis"
name="typeOfRequest"
value={'all'}
checked={requestCategory === 'all'}
onChange={this.handleRequest}
/>
</Form.Field>
</Form.Field>
答案 0 :(得分:0)
要使您的复选框为必填字段,您只需在stateName = ""
def long_name(stAbbrev):
stateName = [key: key for v[stAbbrev]in stateabb.items()]
return stateName
stateName = long_name(state)
组件上添加required
道具:
<Form.Field>