index.js部分constApp=lazy(()=>import('./component/home/App'))constPageA=lazy(()=>import('./component/page-a/Component'));conststore=createStore(Reducers);console.log(store)//路由constRoot=({store})=>();ReactDOM.render(Root(store),document.getElementById('root'));store打印出来是有的在App组件里面只打印this.props只打印出来了history的值
2 回答
阿波罗的战车
TA贡献1862条经验 获得超6个赞
组件还需要被connect起来,声明要获取store里的哪些字段import{connect}from'react-redux'classComponentextendsReact.Component{render(){console.log(this.props)}}constmapStateToProps=state=>{return{哪些你需要的值}}constmapDispatchToProps={...}exportdefaultconnect(mapStateToProps,mapDispatchToProps)(Component)