如果输入无效的邮件id,我需要使用antd工具提示显示“无效的电子邮件!!”。如何在ReactJS antd格式中使用?我现在使用的代码是:
<div style={{'height': '40px','display':'flex'}}>
<label style={{'width':'80px','paddingTop':'8px'}}>Main Email:</label>
<FormItem >
{getFieldDecorator('Email', {
initialValue: '',
rules: [{
type: 'email', message: 'The input is not valid E-mail!',
}],
})(
<Input placeholder="Main Email" style={{'width':'170px'}} onChange={(e)=>{e.preventDefault(); e.stopPropagation();
this.handleChange(0,e, 'Email')}} />
)}
</FormItem> </div>如何使用antd工具提示来修改它以显示消息?
我用工具提示尝试了另一种代码。但问题是
代码是
<div style={{'height': '40px','display':'flex'}}>
<label style={{'width':'80px','paddingTop':'8px'}}>CC Email:</label>
<FormItem >
{getFieldDecorator('Cc', {
initialValue: '',
rules: [{
type: 'email'
},],
})(
<Tooltip title="The input is not valid Email">
<Input placeholder="CC Email" style={{'width':'170px'}} onChange={(e)=>{e.preventDefault(); e.stopPropagation();
this.handleChange(0,e, 'Cc')}} />
</Tooltip>
)}
</FormItem>
</div>发布于 2018-12-04 10:10:41
您可以使用工具提示的visible属性,如下所示:
<FormItem>
{getFieldDecorator("userName", {
rules: [
{
type: "email",
message: (
<Tooltip
visible={true}
title="The input is not valid Email!"
/>
)
}
]
})(
<Input
prefix={<Icon type="user" style={{ color: "rgba(0,0,0,.25)" }} />}
placeholder="Email"
/>
)}
</FormItem>我创建了一个工作演示。
https://stackoverflow.com/questions/53610142
复制相似问题