在 antd Form + ReactJs 中使用 antd Tooltip
Using antd Tooltip within antd Form + ReactJs
如果输入无效的邮件 ID,我需要使用 antd 工具提示来显示 "Invalid Email!!"。
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 修改这个来显示消息?
我尝试了另一个带有工具提示的代码。但问题是
- 它仅在 "hover" 到文本框时有效
- 即使我输入了正确的电子邮件,工具提示仍然存在
密码是
<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
属性 的工具提示,如下所示:
<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>
我创建了一个working demo。
如果输入无效的邮件 ID,我需要使用 antd 工具提示来显示 "Invalid Email!!"。 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 修改这个来显示消息?
我尝试了另一个带有工具提示的代码。但问题是
- 它仅在 "hover" 到文本框时有效
- 即使我输入了正确的电子邮件,工具提示仍然存在
密码是
<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
属性 的工具提示,如下所示:
<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>
我创建了一个working demo。