redux中dispatch = this.props是什么意思?

如题,不知道为什么

var {dispatch} = this.props

为什么要这么写?我console.log出啦props上就是普通的自定义的对象啊

阅读 9.4k
3 个回答

这是es2015的语法 和 var dispatch = this.props.dispatch 等价

dispatch(action)

this.props.dispatch(action)

简洁

ES2015的解构赋值语法

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题