使用Materialize在Aurelia中创建嵌套下拉菜单(导航栏)

问题描述 投票:1回答:1

我想使用Materialise在Aurelia的嵌套Dropdown下创建导航栏。我非常努力。

     <span repeat.for="item of menuItems">
    <ul id="${item.target}"  data-beloworigin="true" class='dropdown-content nested' if.bind="item.type==3"  role="menu">
      <li repeat.for="item of item.items" class.bind="item.class" role.bind="item.role">
        <a if.bind="item.type==3" href="#" class.bind="item.class"role="button" aria-haspopup="true" aria-expanded="false"   href='#' data-target="${item.target}" data-hover="hover" data-alignment="left" > Secondary  ${item.label}
          <span class="caret"></span>
        </a>
        <a if.bind="item.type==0" href.bind="item.url"> ${item.label}</a>
        <a if.bind="item.type==1" href="#" click.delegate="menu(item.param)">  ${item.label}</a>
        </li>
    </ul>
        <ul  if.bind="item.type==3" id="${item.target}" class='dropdown-content'  >
          <li repeat.for="item of item.items" class.bind="item.class" role.bind="item.role">
            <a if.bind="item.type==3" href="#" role="button" aria-haspopup="true"   aria-expanded="false"> ${item.label}
              <span class="caret"></span>
            </a>
            <a if.bind="item.type==0" href.bind="item.url" > Third ${item.label}</a>
            <a if.bind="item.type==1" href="#" click.delegate="menu(item.param)">  ${item.label}</a>
          </li>
        </ul>
  </span>
  <nav class="navbar-default d-flex align-items-center">
    <div class="nav-wrapper">
      <ul class="right hide-on-med-and-down" >
        <li repeat.for="item of menuItems" class.bind="item.class" role.bind="item.role">
          <a if.bind="item.type==3" href="#" class='dropdown-button btn' beloworigin="true" data-target="${item.target}" role="button"
            aria-haspopup="true" aria-expanded="false" >${item.label}

          </a>
          </li>
      </ul>
    </div>
  </nav> 

menuItems从Menu.ts文件中获取菜单。类型3用于父母菜单类型0是将通过单击下拉菜单执行到URL的菜单

我希望当这个代码运行时,菜单栏应该创建,我点击下拉菜单然后应该打开相关的子菜单。

drop-down-menu menu aurelia materialize
1个回答
1
投票

经过一些修改我的代码现在正在运行。

  <span repeat.for="item of menuItems">
    <ul id="${item.target}" class='dropdown-content' if.bind="item.type==3" class.bind="item.class">
      <li repeat.for="item of item.items" class.bind="item.class">
        <a if.bind="item.type==3" href="#" class='dropdown-button' data-hover="hover" data-alignment="left"
          data-target="${item.target}" href='#'> Secondary ${item.label}
          <a if.bind="item.type==0" href.bind="item.url">${item.label}</a>
          <a if.bind="item.type==1" href="#" click.delegate="menu(item.param)"> ${item.label}</a>
        </a>
        <ul id="${item.target}" class='dropdown-content' class.bind="item.class">
          <li repeat.for="item of item.items" class.bind="item.class">
            <a if.bind="item.type==0" href.bind="item.url">${item.label}</a>
            <a if.bind="item.type==1" href="#" click.delegate="menu(item.param)"> ${item.label}</a>
            </a>
          </li>
        </ul>
      </li>
    </ul>
  </span>

  <nav class="navbar-default row mb-0 d-flex align-items-center">
    <div class="nav-wrapper col s12">
      <a href="#" class="left home"><i class="icon icon-propriete"></i></a>
      <ul class="right hide-on-med-and-down">
        <li repeat.for="item of menuItems" class.bind="item.class" role.bind="item.role">
          <a if.bind="item.type==3" href="#" class="dropdown-trigger" data-target="${item.target}">${item.label}

          </a>
        </li>
      </ul>
    </div>
  </nav>
© www.soinside.com 2019 - 2024. All rights reserved.