我安装了babel,也尝试在.babelrc和活着package.json中进行配置
"babel": {
"presets": [
"es2016"
]
},
但是这种语法总是不通过,试了很多方法,谁能指点一下,谢谢各位。
我安装了babel,也尝试在.babelrc和活着package.json中进行配置
"babel": {
"presets": [
"es2016"
]
},
但是这种语法总是不通过,试了很多方法,谁能指点一下,谢谢各位。
挖坟贴
用过下面这种形式吗?
function mapStateToProps(state) {
return { todos: state.todos }
}
function mapDispatchToProps(dispatch) {
return { actions: bindActionCreators(actionCreators, dispatch) }
}
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
接着给他变个样子
export default connect(
state => ({state.todos}),
dispatch => bindActionCreators(actionCreators, dispatch)
)(TodoApp)
这样写看起来很别扭是不是,没事,用修饰器@优化一下。
@connect(
state => ({state.todos}),
dispatch => bindActionCreators(actionCreators, dispatch)
)
export default class TodoApp extends React.Component {
}
换一个姿势,还是同一个东西
那么babel需要配置什么呢
plugins: [
"transform-decorators-legacy"
]
npm 安装
npm i --save-dev babel-plugin-transform-decorators-legacy