Skip to content

Instantly share code, notes, and snippets.

@trejo08
Created July 19, 2019 20:47
Show Gist options
  • Save trejo08/5857eb008899fbca10c8738cf6339d39 to your computer and use it in GitHub Desktop.
Save trejo08/5857eb008899fbca10c8738cf6339d39 to your computer and use it in GitHub Desktop.
List URLs for Vue using VueRouter
import Vue from "vue"
import VueRouter from "vue-router"
const router = new VueRouter({
routes,
})
function getRoutesList(routers, pre) {
return routers.reduce((array, route) => {
const path = `${pre}${route.path}`;
if (route.path !== "*") {
array.push(path);
}
if (route.children) {
array.push(...getRoutesList(route.children, `${path}/`));
}
return array;
}, []);
}
const routerList = getRoutesList(router.options.routes, "http://localhost:3000/app#");
console.log(routerList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment