本文介绍了在antd Form + ReactJs中使用antd工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果输入无效的邮件ID,我需要使用antd工具提示来显示无效的电子邮件!!".如何在ReactJS antd表单中使用它?我现在使用的代码是:
I need to use antd Tooltip to show "Invalid Email!!",if I enter an invalid mail id.How to use it in ReactJS antd Form?The code I am using right now is:
<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工具提示修改此内容以显示消息?
How to modify this using antd Tooltip for showing the message?
我尝试了另一条带有工具提示的代码.但是问题是
I have tried another code with tooltip. But the issues are
- 它仅在悬停"到文本框时有效
- 虽然我输入了正确的电子邮件,但工具提示仍然存在
代码是
<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>
推荐答案
您可以使用 visible
工具提示的属性,如下所示:
You can use the visible
property of tooltip as given below:
<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>
我创建了一个工作演示.
这篇关于在antd Form + ReactJs中使用antd工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!