我的路线配置如下(反应路由器3):
rl <- rle(dat$strength)
aggregate(days ~., transform(dat, Group = rep(seq_along(rl$values),
rl$lengths))[-5], FUN = sum)[-4]
# id name strength days
#1 1 a 10 60
#2 1 a 5 30
#3 1 a 10 20
#4 2 b 10 15
&#13;
每个子路线都在&#34; App&#34;零件。我想要做的是创建另一个组件,它将是&#34;外部&#34;一。这意味着我的新组件,即#13; OutsideComponent&#34;,应该单独呈现(不在App组件内)。有人可以帮我配置这样的配置吗?
答案 0 :(得分:0)
React router v3
配置是一个对象(不是数组)。所以你应该有一个根组件,其他任何路由都是子路由。可能低于配置将适合您。
尽量让您的应用尽可能简单。并使用childRoutes来实现您的配置
...
path: '/',
component: Root, // Just a component which actually renders children and nothing else
childRoutes: [{
path: '/',
component: App,
childRoutes: {} //Your App components children goes here.
}, {
path: '/YOUR_NEW_PATH', // not a part of your App
component: YOUR_COMPONENT, // not a child of your APP
childRoutes: {} // If you have some childRoutes
}]
...
您的Root组件可能看起来像组件
Root = (props) => <div>{props.children}</div>