- hashHistory.push传参
hashHistory.push({
pathname: '/apartmentReserve/'+id,
query: {
name: name,
price: price
},
})
跳转之后页面接收参数
componentWillMount(){
apartmentData={
apartmentId:this.props.params.apartmentId,
name:this.props.location.query.name,
price:this.props.location.query.price
}
}
- input设置默认值
//text类型
<input type="text" defaultValue={ 默认值 } />
//checkbox类型
<input type="checkbox" defaultChecked="true" />
- 定时触发事件,setTimeout
class A extends React.Component{
handleChange(target){
var that = this;
if(this.timer){
clearTimeout(this.timer);
}
this.timer = setTimeout(()=>{
that.setState({
xxx:target.value
});
},500);
}
render(){
return(
<input onChange={this.handleChange} xxxxxx />
)
}
}