Created
March 9, 2019 17:02
-
-
Save reinink/2488a5ff6c314eddba50b0a6932c72d9 to your computer and use it in GitHub Desktop.
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
<template> | |
<nav> | |
<a :class="isUrl('') ? 'active' : 'not-active'" href="/">Dashboard</a> | |
<a :class="isUrl('users') ? 'active' : 'not-active'" href="/users">Users</a> | |
<a :class="isUrl('reports') ? 'active' : 'not-active'" href="/reports">Reports</a> | |
</nav> | |
</template> | |
<script> | |
export default { | |
methods: { | |
isUrl(...urls) { | |
if (urls[0] === '') { | |
return location.pathname.substr(1) === '' | |
} else { | |
return urls.filter(url => location.pathname.substr(1).startsWith(url)).length | |
} | |
}, | |
}, | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment