1

update;

    <template>
  <div class="container">
    <div class="dropdown">
      <button class="btn btn-default" @click="toggleDropdown">Tutorials <span class="caret"></span></button>
      <ul class="dropdown-menu" v-show="dropdownOpen" @click.stop="">
        <li>
          <a href="#">HTML</a>
        </li>
        <li>
          <a href="#">CSS</a>
        </li>
        <li class="dropdown-submenu">
          <a href="#" @click="toggleSubmenu">New dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu" v-show="submenuOpen">
            <li>
              <a href="#">2nd level dropdown</a>
            </li>
            <li>
              <a href="#">2nd level dropdown</a>
            </li>
            <li class="dropdown-submenu">
              <a href="#" @click="toggleSubmenu">Another dropdown <span class="caret"></span></a>
              <ul class="dropdown-menu" v-show="submenuOpen">
                <li>
                  <a href="#">3rd level dropdown</a>
                </li>
                <li>
                  <a href="#">3rd level dropdown</a>
                </li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dropdownOpen: false,
      submenuOpen: false
    };
  },
  methods: {
    toggleDropdown() {
      this.dropdownOpen = !this.dropdownOpen;
    },
    toggleSubmenu() {
      this.submenuOpen = !this.submenuOpen;
    }
  }
};
</script>

<style>
.dropdown-submenu {
  position: relative;
}
.dropdown-submenu .dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -1px;
}
</style>

it is not working and there is no error in my console.. idk how can i make a nested dropdown menu in vuejs 2 ?

4
  • 1
    Are you using bootstrap?
    – kissu
    Commented May 10, 2024 at 12:59
  • it is a very big project and I use bootstrap too, but also other UI frameworks and libraries
    – dkrks
    Commented May 10, 2024 at 13:01
  • 1
    Try to reproduce it at a smaller scale then. No point in having side-effects. That would be a great opportunity to have some minimal reproducible example for us.
    – kissu
    Commented May 10, 2024 at 13:02
  • i updated my code, could you please take a look it ?
    – dkrks
    Commented May 13, 2024 at 7:24

1 Answer 1

1

According to the official documentation of BootstrapVue, it does not support the integration of nested dropdown menus. Therefore, you cannot achieve it specifically with BootstrapVue components.

Note: Nested sub-menus are not supported.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.