面试题答案
一键面试import React from'react';
// 定义路由配置对象的类型
type RouteConfig = {
path: string;
component: React.ComponentType;
};
// 定义函数,接受路由路径和组件类型,返回路由配置对象
function createRoute(path: string, component: React.ComponentType): RouteConfig {
return {
path,
component
};
}