我的路由器如下所示,
[
{
path: '/',
component: App,
childRoutes: [
{
path: 'dashboard',
getComponent: function(location, cb) {
require.ensure([], function(require) {
cb(null, require('../plugins/dashboard/index'))
})
},
childRoutes: [
{
path: '/:id',
getComponent: function(location, cb) {
require.ensure([], function(require) {
cb(null, require('../plugins/dashboard/saved_dashboard'))
})
}
}
]
},
{
path: 'profile',
getComponent: function(location, cb) {
require.ensure([], function(require) {
cb(null, require('../plugins/profile/index'))
})
}
}
]
}
];
我的菜单组件示例代码看起来像
<ul id='menu'>
<li>
<Link to='dashboard'>dashboard</Link>
</li>
<li>
<Link to='dashboard/mydashboard'>my dashboard</Link>
</li>
<li>
<Link to='profile'>profile</Link>
</li>
</ul>
问题是当我点击“我的仪表板”然后它会路由到
localhost/dashboard/mydashboard
如果我再点击“我的信息中心”,它会路由到
localhost/dashboard/mydashboard/dashboard/mydashboard
继续前进。
如何解决此问题?我在哪里犯了错误? 或者我必须在配置中做更多的事情?
答案 0 :(得分:1)
原因是to
的{{1}}参数采用绝对路径,而您的路径是相对的......
所以要解决它,它应该看起来像:
Link