【发布时间】:2016-08-22 08:45:16
【问题描述】:
我正在尝试验证我的登录表单并使用 https://github.com/christianalfoni/formsy-react 上的示例
我对 react 和 formy 都是新手。
我收到“未捕获的 ReferenceError: MyOwnInput is not defined”的错误
我的代码是这样的
import Formsy from 'formsy-react';
import React, { Component } from 'react';
import {Link} from "react-router";
import {withRouter} from 'react-router';
export default withRouter(class Testing extends React.Component{
constructor(props){
super(props);
this.state= {
canSubmit: false
};
}
enableButton() {
this.setState({
canSubmit: true
});
}
disableButton() {
this.setState({
canSubmit: false
});
}
submit(model) {
someDep.saveEmail(model.email);
}
render() {
return (
<Formsy.Form onValidSubmit={this.submit} onValid={this.enableButton} onInvalid={this.disableButton}>
<MyOwnInput name="email" validations="isEmail" validationError="This is not a valid email" required/>
<button type="submit" disabled={this.state.canSubmit}>Submit</button>
</Formsy.Form>
);
}
});
【问题讨论】:
-
MyOwnInput 组件的导入在哪里?
-
你所说的 Import Myowncomponent 是什么意思......我必须从哪里导入它?
-
我只是第一次听说。
-
我不明白什么是 MyOwnInput。 import Formsy from 'formsy-react' 适用于
但 MyOwnInput 是 Formsy 的一部分还是您自己的组件?也许会像 import MyOwnInput from '../../components/common/MyOwnInput'; -
你能告诉我,我在那个组件中到底要写什么......就像我根本没有得到你一样
标签: javascript validation reactjs formsy-react