所有的demo源码:https://github.com/Ching-Lee/react-base
1.表单的常见操作
demo09
!DOCTYPE html>
Form
2.多个input文件上传
可以只写一个handleInputChange函数,根据类型不同来修改不同的state对象的属性。
class Reservation extends React.Component {
constructor(props) {
super(props);
this.state = {
isGoing: true,
numberOfGuests: 2
};
this.handleInputChange = this.handleInputChange.bind(this);
}
handleInputChange(event) {
const target = event.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name;
this.setState({
[name]: value
});
}
render() {
return (
);
}
}