Aurelia:如何使用一些下拉菜单项构建主菜单

时间:2017-01-06 12:41:08

标签: twitter-bootstrap aurelia aurelia-router aurelia-framework

我是aurelia框架的新手。我尝试构建一个共有7个项目的主菜单。前4项应为顶级菜单项,最后3项为下拉菜单。我使用bootstrap 3。

app.ts中的路由器配置如下:

config.map([
  { route: ['', 'Buchungen'],
    name: 'Buchungen',
    moduleId: './buchung/app-buchung',
    nav: true, title: 'Buchungen',
    settings: {img:'./img/ic_tab_buchungen_white.png',t:'main_Buchungen',class:'fa fa-money'}},
  { route: 'Konten',
    name: 'Konten',
    moduleId: './konto/app-konto',
    nav: true,
    title: 'Konten',
    settings: {img:'./img/ic_tab_konto_white.gif',t:'main_Konten',class:'fa fa-university' }},
  { route: 'Bilanz',
    name: 'Bilanz',
    moduleId: './bilanz/app-bilanz',
    nav: true,
    title: 'Bilanz',
    settings: {img:'./img/ic_tab_bilanz_white.gif',t:'main_Bilanz',class:'fa fa-balance-scale'} },
  { route: 'Erfolg',
    name: 'Erfolg',
    moduleId: './erfolg/app-erfolg',
    nav: true,
    title: 'Erfolg',
    settings: {img:'./img/ic_tab_erfolg_white.gif',t:'main_Erfolg',class:'fa fa-line-chart'} },
  { route: 'Chart',
    name: 'Chart',
    moduleId: './child-router',
    nav: true,
    title: 'Chart',
    settings: {img:'./img/chart_line32.png',t:'menu_chart',class:'fa fa-area-chart'} },
  { route: 'export',
    name: 'export',
    moduleId: './child-router',
    nav: true,
    title: 'export',
    settings: {img:'./img/ic_menu_export.png',t:'menu_export', class:'glyphicon glyphicon-log-out'}},
  { route: 'option',
    name: 'option',
    moduleId: './child-router',
    nav: true,
    title: 'option',
    settings: {img:'./img/ic_menu_export.png',t:'menu_option', class:'glyphicon glyphicon-option-horizontal'}}
]);

nav-bar.html看起来像:

<div class="collapse navbar-collapse" id="aaccounting-navigation-navbar-collapse">
    <ul class="nav navbar-nav">
      <li repeat.for="row of router.navigation" class="${row.isActive ? 'active' : ''}">
        <a data-toggle="collapse" data-target="#aaccounting-navigation-navbar-collapse.in" href.bind="row.href" >
          <i class="${row.settings.class}" aria-hidden="true"></i>
          <span t.bind="row.settings.t">${row.title}</span>
        </a>
      </li>

在上面的html中,将连续有7个菜单项,但我喜欢将下拉菜单设为:

<li>
        <a href="#" data-toggle="dropdown" class="dropdown-toggle">Dropdown <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
        </ul>

      </li>

我怎么能用aurelia做到这一点?

1 个答案:

答案 0 :(得分:1)

也许,这个答案对你有帮助:https://stackoverflow.com/a/38444441/4921289

他的建议是在路线配置设置属性(您已经做过的事情)中添加属性,以区分下拉条目或主条目。