react全局注入mobx,代码实现通过Provider传入,内嵌router。在子组件中拿不到传入的storeimport React from 'react'import { observer,Provider,inject } from 'mobx-react'import Router from '@/routers'import AppStore from '@/stores/app'@observerclass App extends React.Component{
render(){ return ( <Provider store={AppStore}>
<Router/>
</Provider>
)
}
}export default App代码已上传到 github
1 回答
繁星淼淼
TA贡献1775条经验 获得超11个赞
<Provider AppStore={AppStore}> <Router/></Provider>
子组件注入下,@inject('AppStore')
添加回答
举报
0/150
提交
取消