多个action组成一个文件
方法1.
const mapDispatchToProps = (dispatch, ownProps) => {
return{
actions : bindActionCreators(Actions,dispatch),
actions1 : bindActionCreators(Actions,dispatch)
}
}
调用:
this.props.actions.xxx()
this.props.actions1.xxx()
方法2.
import * as actions from '../actions/';
function mapDispatchToProps (dispatch) {
return bindActionCreators(
Object.assign({}, ...Object.keys(actions).map(key => ({[key]: actions[key]}))),
dispatch
);
}
参考:https://segmentfault.com/q/1010000007800659/a-1020000007800942