React依赖:
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1"
},
"dependencies": {
"classnames": "^2.2.5",
"react": "^16.1.1",
"react-dom": "^16.1.1"
}
第一步,创建reducer文件下的index.js
第二步,在main.js中创建store--{createStore}
第三步,共享store--{Provider}
让所有下辖的组件都可以使用store
第四步,更改app组件
1)引入connect组件
2)export default connect() (app); 装饰者模式--将app装饰后暴露