Created
August 26, 2019 09:49
-
-
Save cristijora/54ac2fead1c895498a6f67d1c35a60e9 to your computer and use it in GitHub Desktop.
Collapse menus Vue Paper Dashboard PRO
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
// SidebarPlugin/index.js | |
const SidebarStore = { | |
// other code, | |
linksStore: [], | |
addSidebarLink(link) { | |
this.linksStore.push(link) | |
}, | |
removeSidebarLink(link) { | |
const index = this.sidebarLinks.indexOf(link) | |
this.linksStore.splice(index, 1) | |
}, | |
collapseAllMenus() { | |
this.linksStore.forEach(link => { | |
link.collapsed = true | |
}) | |
} | |
} | |
// SidebarItem.vue | |
methods: { | |
//other code | |
collapseMenu() { | |
this.$sidebar.collapseAllMenus() | |
this.collapsed = !this.collapsed | |
} | |
}, | |
mounted() { | |
// other code | |
this.$sidebar.addSidebarLink(this) | |
}, | |
destroyed() { | |
// other code | |
this.$sidebar.removeSidebarLink(this) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment