Added matcher prop for menu

This commit is contained in:
Grzegorz Leoniec 2019-01-14 16:05:55 +01:00
parent 1cb4156422
commit 598dd9cda7
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377
2 changed files with 15 additions and 0 deletions

View File

@ -98,6 +98,15 @@ export default {
return route.name
}
},
/**
* Function that matches items exactly
*/
matcher: {
type: Function,
default: () => {
return false
}
},
/**
* Function that checks if the url must be matched exactly in order to activate the menu item. By default only '/' must be matched exactly.
*/

View File

@ -14,6 +14,9 @@
<component
v-if="route"
class="ds-menu-item-link"
:class="[
matcher && 'router-link-exact-active'
]"
v-bind="bindings"
:exact="isExact"
:is="linkTag"
@ -106,6 +109,9 @@ export default {
isExact() {
return this.$parentMenu.isExact(this.url)
},
matcher() {
return this.$parentMenu.matcher(this.url, this.route)
},
level() {
return this.parents.length
},