如何解决如何在循环中验证所有 reduxForm 字段?
我有一个授权表,其中存在 2 个 <Col></Col>
,而且很容易验证。这是我的做法:
Field
const reducers = {
// ... your other reducers here ...
form: formReducer
}
const reducer = combineReducers(reducers)
const store = createStore(reducer)
class Authorization extends Component {
constructor() {
super();
}
render() {
return (
<Provider store={store}>
<AuthForm/>
</Provider>
)
}
}
AuthForm extends Component {
validate_login = values => {
console.log("Validating login... Login is",values)
}
validate_pwd = values => {
console.log("Validating password... Passwd is",values)
}
render() {
const { handleSubmit } = this.props
return (
<form onSubmit={handleSubmit} className="authorization-center-wrapper">
<div className="authorization-column-wrapper">
<label className="authorization-RTA-text" onClick={this.home_page}>RTA</label>
<label className="authorization-auto-text">AUTH</label>
<div className="authorization-center-content">
<Field validate={[this.validate_login]} name={"login"} component={'input'} type="text" placeholder="Email" className="authorization-login-input"/>
<Field validate={[this.validate_pwd]} name={"password"} component={'input'} type="password" placeholder="Password" className="authorization-password-input"/>
<button className="authorization-come-in-btn" type={"submit"}>Log in</button>
<p className="authorization-forgot-password" onClick={this.forgot_pass}>Forgot password?</p>
<Link to={"/reg"} className="authorization-reg-btn" onClick={this.reg_page}>Sign up</Link>
</div>
</div>
</form>
)
}
}
AuthForm = reduxForm({
// a unique name for the form
form: 'authorization'
})(AuthForm)
ReactDOM.render(<Authorization/>,document.getElementById("root"));
现在工作正常,但我有注册表,其中有 10 个字段。是否存在任何循环或用于检查值是否为空的循环? (最好没有验证属性),我在互联网上找不到任何解决方案。
无法制作可重现的代码,因为不知道如何在 stackoverflow 中使用 react
提前致谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。