// 该运行时用于修改路由对应的页面组件,给其加上errorBoundary function modify(routes = []) { const loop = (routeList) => { routeList.forEach((route) => { if (route.component) { if (!route.component.pageConfig) { route.component.pageConfig = {}; } if (typeof route.component.pageConfig.errorBoundary === 'undefined') { route.component.pageConfig.errorBoundary = true; } } if (route.children && route.children.length) { loop(route.children); } }) } loop(routes); return routes; } export default ({ modifyRoutes }) => { // router 为 false 时,该方法不存在 if (modifyRoutes) { modifyRoutes((routes) => { const modifiedRoutes = modify(routes); // 修改路由 return modifiedRoutes; }); } };