Created
July 19, 2019 20:47
-
-
Save trejo08/5857eb008899fbca10c8738cf6339d39 to your computer and use it in GitHub Desktop.
List URLs for Vue using VueRouter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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