no message
This commit is contained in:
@@ -21,11 +21,8 @@ export default class Count extends Component{
|
||||
}
|
||||
}
|
||||
increementSync=()=>{
|
||||
// const {value}=this.selectNumber
|
||||
// const {count}=this.state
|
||||
// setTimeout(()=>{
|
||||
// this.setState({count:count+value*1})
|
||||
// },1000)
|
||||
const {value}=this.selectNumber
|
||||
this.props.jiaAsync(value*1,1000)
|
||||
}
|
||||
render(){
|
||||
return(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import countUI from '../../components/count'
|
||||
import {connect} from 'react-redux'
|
||||
import {createIncreementAction,createDecreementAction} from '../../redux/count_action'
|
||||
import {createIncreementAction,createDecreementAction,createIncreementAsyncAction} from '../../redux/count_action'
|
||||
|
||||
function mapStateToProps(state){
|
||||
return {state}
|
||||
@@ -8,7 +8,8 @@ function mapStateToProps(state){
|
||||
function mapDispatchToProps(dispatch){
|
||||
return {
|
||||
jia:data=>dispatch(createIncreementAction(data)),
|
||||
jian:data=>dispatch(createDecreementAction(data))
|
||||
jian:data=>dispatch(createDecreementAction(data)),
|
||||
jiaAsync:data=>dispatch(createIncreementAsyncAction(data,time)),
|
||||
}
|
||||
}
|
||||
const CountContainer=connect(mapStateToProps,mapDispatchToProps)(countUI)
|
||||
|
||||
@@ -11,7 +11,16 @@ function createIncreementAction(data){
|
||||
function createDecreementAction(data){
|
||||
return {type:DECREEMENT,data}
|
||||
}
|
||||
function createIncreementAsyncAction(data,time){
|
||||
// store调用createIncreementAsyncAction 能接收一个参数dispatch
|
||||
return (dispatch)=>{
|
||||
setTimeout(()=>{
|
||||
dispatch(createIncreementAction(data))
|
||||
},time)
|
||||
}
|
||||
}
|
||||
export {
|
||||
createIncreementAction,
|
||||
createDecreementAction
|
||||
createDecreementAction,
|
||||
createIncreementAsyncAction
|
||||
}
|
||||
Reference in New Issue
Block a user