mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
35 lines
740 B
JavaScript
35 lines
740 B
JavaScript
const registerRoute = (navConfig, isExample) => {
|
|
let route = [];
|
|
let navs = navConfig['zh-CN'];
|
|
navs.forEach(nav => {
|
|
if (nav.groups) {
|
|
nav.groups.forEach(group => {
|
|
group.list.forEach(nav => {
|
|
addRoute(nav);
|
|
});
|
|
});
|
|
} else if (nav.children) {
|
|
nav.children.forEach(nav => {
|
|
addRoute(nav);
|
|
});
|
|
} else {
|
|
addRoute(nav);
|
|
}
|
|
});
|
|
|
|
function addRoute(page) {
|
|
route.push({
|
|
path: '/component' + page.path,
|
|
component: function(resolve) {
|
|
require([isExample ? `./examples-dist${page.path}.vue` : `./examples-docs${page.path}.md`], resolve);
|
|
}
|
|
});
|
|
}
|
|
|
|
// console.log(route);
|
|
|
|
return route;
|
|
};
|
|
|
|
export default registerRoute;
|