使用PlainRoute将组件数组传递给布局

时间:2016-07-21 21:34:08

标签: javascript reactjs react-router

我想将一组数组[AccountSettings, PlanSettings]传递给我的SettingsLayout

如何使用react-router的PlainRoute?

执行此操作
export default {
  path: 'settings',
  component: SettingsLayout,
  childRoutes: [
    {
      path: 'account',
      component: [AccountSettings, PlanSettings]
    },
    {
      path: 'notifications',
      component: NotificationSettings
    }
  ]
}

1 个答案:

答案 0 :(得分:0)

使用components https://github.com/reactjs/react-router/blob/master/docs/API.md#components-1

并传递一个对象:

components: {AccountSettings, PlanSettings}

您甚至可以这样做:

components: { components: [ AccountSettings, PlanSettings ] }

但是我还没有尝试过......即使你可以,它似乎并不是非常有用。