router.config.js
const routes = []
router.view.js
import React, { Component } from ‘react’
import { Switch, Route, Redirect } from ‘react-router-dom’
export default class Index extends Component {
render() {
const { routes } = this.props
const normalRoutes = routes.filter(item => !item.to)
const redirectRoutes = routes.filter(item => item.from).map((item, key) => )
return (
{
normalRoutes && normalRoutes.map((item, key) => <Route key={key} path={item.path}
render={props => <item.component {…props} routes={item.children}></item.component>}>).concat(redirectRoutes)
}
)
}
}