react.js - 用react-redux包装了了react-router,结果组建中的props只有reducers中的参数,见详情

查看:95
本文介绍了react.js - 用react-redux包装了了react-router,结果组建中的props只有reducers中的参数,见详情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

路由大妈

<Provider store={store}>
    <Router history={browserHistory}>
      <Route path="/">
        <Route path="/signin" component={Signin}/>
        <Route path="/signup" component={SignUp}/>
        <Redirect from="/main" to="/main/list" />
        <Route path="/main" component={Layout} >
          <Route path="chat" component={App}/>
          <Route path="list/:id" component={Code}/> //这里你们看我设了URL参数
          <Route path="list" component={Code}/>
        </Route>
        <Route path="/article/:id" component={Article}/>
        <Redirect from="/article" to="/main/list" />
      </Route>
    </Router>
  </Provider>

然而我在组件中 ,log this.props 的时候发现只有reduces中的参数,并没有 this.props.location这个!跟谈不上那params了,
求解救
百度了好久没找到
我觉得是我redux不熟的问题,因为百度上并没有人问,大概是说,有人用url控制陆游,redux有另外一套东西????

如果不用redux,去掉都去掉!之后在组件中log this。props 就会这么些个东西

这个问题已被关闭,原因:问题质量差 - 问题太水、伸手党

解决方案

建议你看下react-router-redux,获取能帮到你

这篇关于react.js - 用react-redux包装了了react-router,结果组建中的props只有reducers中的参数,见详情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆