我对这个简单的问题感到很难过!我想简单地获取表单数据,验证它,提交它并向Express API提交发布请求.但在此之前,我认为我没有彻底了解如何实现这一目标.我看了看这个问题,这些和一堆人,但我不知道这是最好的办法.
这是我假设将采取的方式:
我为注册页面创建了一个React组件.(简化用于演示)
class SignupForm extends Component {
constructor(props){
super(props);
this.onSubmit = this.onSubmit.bind(this);
}
onSubmit(val){
debugger;
}
render(){
return (
<form onSUbmit={ (e)=> this.onSubmit(e) }>
<input type="text" />
<label></label>
<button type="submit">Submit</button>
</form>
)
}
}
Run Code Online (Sandbox Code Playgroud)
单击按钮时,将触发OnSubmit()函数,在该函数中将传递JSON数据.
{
"name": "Kanye",
"surname": "West",
"email":"yeezy@goodmusic.com",
"password":"notsurehowthiswillwork"
}
Run Code Online (Sandbox Code Playgroud)
在哪里我可以触发我的动作
SignupAction(),这将对我的API进行AJAX调用,然后更新我的reducer.
当使用像react-redux-form或redux- forms这样的库时,混淆成倍增加.我只是想简单有一个模型或东西name,surname email和password,但我觉得这些库,尽快为他们开始有喜欢自己减速过度设计:
const store = createStore(combineForms({
user: initialUser,
}));
Run Code Online (Sandbox Code Playgroud)
我的其他选择是:
class SignupForm extends Component {
constructor(props){
super(props); …Run Code Online (Sandbox Code Playgroud) 我正在尝试为十进制格式的特定图形设置选项。我遇到了许多问题,但似乎无法弄清楚为什么它对我不起作用。
var temp_chart_options = {
title: 'Temperature',
hAxis: {title: 'Date', titleTextStyle: {color: '#262626'}, format:'decimal' },
vAxis: {minValue: 0, format: 'decimal'},
keepInBounds: true,
};
temp_chart.draw(temp_data, temp_chart_options);
Run Code Online (Sandbox Code Playgroud)
我尝试做format: 'decimal',或者format: { pattern: 'decimal' }甚至做了temp_chart.draw(data, google.charts.Line.convertOptions(temp_chart_options));,甚至看着这些问题:
但是它们似乎都不起作用:(
编辑