Skip to content

Instantly share code, notes, and snippets.

@ritchie46
Last active April 30, 2018 09:17
Show Gist options
  • Save ritchie46/d8d660616dc1212b371391137d2f2ade to your computer and use it in GitHub Desktop.
Save ritchie46/d8d660616dc1212b371391137d2f2ade to your computer and use it in GitHub Desktop.
vue-navigation_component-side
<template>
<nav>
<ul class="pagination">
<li v-for="page in navs" class="page-item"
v-bind:class="{active: activeId === page.id}" v-bind:id="page.id">
<a class="page-link" v-on:click="toggle">
{{ page.name }}
</a>
</li>
</ul>
</nav>
</template>
<script>
export default {
name: "navigator",
props: ['navs', 'active'],
data: function () {
return {
activeId: this.active
}
},
methods: {
toggle: function (e) {
this.activeId = e.target.parentElement.id;
this.$parent.$emit('activeNavigation', this.activeId);
}
}
}
</script>
<style scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment