import React from 'react' ; import { matchPath } from 'react-router-dom' ; import { FC } from './interface/fc' ; import { RouteItem } from './interface/route' ; const NotFound = ( ) => { return ( < div > 路由查询404 < /div>); } ; const getComponent = ( Routes , path ) => { const activeRoute = Routes . find ( route => matchPath ( path , route ) ) || { Component : ( ) => NotFound } ; const activeComponent = activeRoute . Component ; return activeComponent ; } ; export default getComponent ;