vuesax icon indicating copy to clipboard operation
vuesax copied to clipboard

v-model not doing anything on sidebar

Open ashleymoogle opened this issue 5 years ago • 2 comments

OS: MacOs Node : 10.15.1 Vuesax: 3.8.24 Browser: Chrome 72.0.3626.121 (Official Build) (64-bit) Package manager: Yarn

Hello! I'm having trouble with the active class feature of the slidebar coupled with the vue-router. The v-model doesn't seem to do anything and as far as I know there is no way to set the correct active state on page load. Any ideas?

ashleymoogle avatar Mar 07 '19 23:03 ashleymoogle

Hi, active prop is just there to hide and show sidebar. It has nothing to do with active item in sidebar. For vue-router and sidebar's active item, You can try changing class of vue-router using linkActiveClass: 'active', instead of active there will be vuesax active link class when clicked.

Let me know if it works.. ~ Cheers

jsinhSolanki avatar Mar 08 '19 06:03 jsinhSolanki

Since documentation is very limited, I think I'm gonna bump this for anyone can't figure it out . You can do something like this;

<template>
  <vs-sidebar v-model="active"> <!-- This model is for hide/show sidebar -->
    <vs-sidebar-item to="/" :class="{ active: isActive('home'), link: true }">
      Home
    </vs-sidebar-item>
    <vs-sidebar-item to="/about" :class="{ active: isActive('about'), link: true }">
      About
    </vs-sidebar-item>
  </vs-sidebar>
</template>

<script>
export default {
  data: () => {
    return {
      active: "",
    }
  },
  methods: {
    isActive(route) {
      return this.$route.name && route === this.$route.name.toLowerCase();
    }
  }
}
</script>

It should add .active class to vs-sidebar-item. Means you will see active route in your sidebar.

Alcadramin avatar Mar 19 '21 04:03 Alcadramin