My navigation gets the routes from the vue-router, so that I do not have to add them manually.
These routes have a meta boolean key called "inMenu", as well as their child routes. I only manage to filter the parent routes but not the child routes.
var res = this.$router.options.routes.filter(function f(o) {
if (o.route.meta.inMenu === true) return true
if (o.children) {
return (o.children = o.children.filter(f)).length
}
})
This is how I filter the parent routes but I can't manage it to filter the children.
return this.$router.options.routes.filter(route => route.meta.inMenu === true);
This is some sample data:
{
"path": "/orders",
"component": {
"name": "Orders",
"__file": "src/views/Orders.vue",
},
"meta": {
"icon": "fa-history",
"title": "Abwicklungen",
"inMenu": true
},
"children": [
{
"path": "list",
"name": "orderList",
"component": {
"name": "OrderList",
"__file": "src/views/orders/list.vue",
},
"meta": {
"title": "Bestellliste",
"icon": "fa-circle-o",
"inMenu": true
}
},
{
"path": "details/:id",
"name": "orderDetails",
"component": {
"name": "OrderDetails",
"__file": "src/views/orders/details.vue"
},
"meta": {
"title": "Bestellung",
"icon": "fa-circle-o",
"inMenu": false
}
},
{
"path": "dailyclosing",
"component": {
"name": "OrderList",
"__file": "src/views/orders/list.vue",
},
"meta": {
"title": "Tagesabschluss",
"icon": "fa-check",
"inMenu": true
}
}
]
}
I want to have each route and children not shown if inMenu is false.