Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <!-- Load required Bootstrap and BootstrapVue CSS -->
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css" />
<!-- Load polyfills to support older browsers -->
<script src="//polyfill.io/v3/polyfill.min.js?features=es2015%2CIntersectionObserver" crossorigin="anonymous"></script>
<!-- Load Vue followed by BootstrapVue -->
<script src="//unpkg.com/vue@latest/dist/vue.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.js"></script>
<!-- Load the following for BootstrapVueIcons support -->
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue-icons.min.js"></script>
</head>
<body>
<div id="app">  
  <b-dropdown id="dropdown-1" text="Dropdown Button" class="m-md-2">
    <b-dropdown-item 
     v-for="(item,index) in menu"  
     :key="index"
     @mouseover.native="toogleItem(index)"
     @mouseout.native="toogleItem(index)">
      <span>{{item.title}} <b-icon-caret-down-fill :scale="0.6" v-if="item.children"></b-icon-caret-down-fill></span>
        <div v-if="item.children" class="sub-menu" v-show="item.showSubMenu">
            <b-dropdown-item v-for="(item,index) in item.children" :key="index">{{item.title}}
            </b-dropdown-item>   
        </div>
    </b-dropdown-item>   
  </b-dropdown>
</div>
</body>
</html>
 
.sub-menu{
  position: absolute;            
    min-width: 10rem;
    padding: .5rem 0;
    margin: .125rem 0 0;
    font-size: 1rem;
    color: #212529;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: .25rem;
}
 
new Vue({
  el: "#app",
  data: {
    menu: [
        { title : 'one'},
      { title : 'two'},
      { title : 'three',showSubMenu : false,
        children : [
          { title : 'four'},
          { title : 'five'},
      ]},
    ]  
  },
  methods : {       
    toogleItem(index){
      if(this.menu[index].children){
          if(!this.menu[index].showSubMenu){
            this.menu[index].showSubMenu = true
          } else {
            this.menu[index].showSubMenu = false
          }
      }
      
    }
  }
})
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers