本ajax封装代码:
const AjaxSend = function( action, url, data, callback ){
var settings = {
async: true,
crossDomain: true,
url: "" + url,
method: action,
data: data
}
$.ajax(settings).done(function (response) {
callback(response)
});
}
export default AjaxSend;
表单代码:
class Login extends React.Component {
constructor(props){
super(props);
this.state = {
email:"",
password:"",
};
this.handleChange = this.handleChange.bind(this)
}
handleChange(e) {
this.setState({[e.target.name]: e.target.value})
}
handleSubmit(e) {
e.preventDefault();
//写
}
render(){
var email = this.state.email;
var password = this.state.password;
return (
) ;
}
}
export { Login as default } ;