这是我正在使用的代码。我想知道条件运算符的语法正确与否吗?
<Col span={12}>
<FormItem label="Admin User Name">
{getFieldDecorator('username', {
initialValue: this.state.userName,
rules: [{
required: this.props.userNameExist === true ? {message: 'Please Input user name!'} : {message: 'User Name already Exists!'}
}],
})(
<Input name="userName" placeholder="Admin UserName"
onChange={(e) => {
e.preventDefault(); e.stopPropagation();
this.handleChange(e)
}}
/>
)}
</FormItem>
</Col>
这是我想知道语法是否正确的代码行。
this.props.userNameExist === true ? {message: 'Please Input user name!'} : {message: 'User Name already Exists!'}