javascript - 在react-router中加一层路由出问题

查看:113
本文介绍了javascript - 在react-router中加一层路由出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

之前的代码是

<td><Link to={`/settings/dicts/${row.id}`}>{row.k}</Link></td>

                    <Route path="dicts">
                        <IndexRoute components={{sidebar: Settings, main: DictsPage}}/>
                        <Route path=":id" components={{sidebar: Settings, main: DictPage}}/>
                    </Route>

之后的代码是

<td><Link to={`/settings/dicts/hh/${row.id}`}>{row.k}</Link></td>

                    <Route path="dicts">
                        <IndexRoute components={{sidebar: Settings, main: DictsPage}}/>
                        <Route path="hh/:id" components={{sidebar: Settings, main: DictPage}}/>
                    </Route>

代码改了之后就出问题了

请问这种情况怎么解决呢?

解决方案

稍微改一下路径方式吧 hh/:id 改成hh_:id
同理上面也改了

<td><Link to={`/settings/dicts/hh_${row.id}`}>{row.k}</Link></td>

这篇关于javascript - 在react-router中加一层路由出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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