【发布时间】:2019-05-05 17:08:52
【问题描述】:
如果我输入了无效的邮件ID,我需要使用antd Tooltip显示“无效的电子邮件!!”。 如何在 ReactJS antd Form 中使用它? 我现在使用的代码是:
<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 Tooltip 修改这个来显示消息?
我尝试了另一个带有工具提示的代码。但问题是
- 只有在“悬停”到文本框时才有效
- 即使我输入了正确的电子邮件,工具提示仍然存在
代码是
<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>
【问题讨论】:
-
您好,请提供最低限度的复制品