react全局注入mobx,代码实现通过Provider传入,内嵌router。在子组件中拿不到传入的store
import React from 'react'
import { observer,Provider,inject } from 'mobx-react'
import Router from '@/routers'
import AppStore from '@/stores/app'
@observer
class App extends React.Component{
render(){
return (
<Provider store={AppStore}>
<Router/>
</Provider>
)
}
}
export default App
代码已上传到 github
子组件注入下,@inject('AppStore')