更改在单击数据绑定上显示的纸张选项卡 - 聚合物

时间:2017-07-06 07:59:24

标签: javascript html tabs polymer

当我选择边栏上的按钮时,我想动态更改页面中显示的纸张标签。

即。 (选择|标签显示)

专家| 3个标签

管理员| 4个标签

当我根据可滚动对话框中显示的数据选择标签本身时,我已设法使数据绑定正常工作,我只是坚持这一点。

页-tabs.html

<!-- THIS IS STILL A PRETTY BASIC EXAMPLE --> 
<paper-tabs selected="{{selected}}" noink>
   <paper-tab link>
      <a href="#tab1" tabindex="-1">TAB 1</a>
    </paper-tab>
    <paper-tab link>
      <a href="#tab2" tabindex="-1">TAB 2</a>
    </paper-tab>
    <paper-tab link>
      <a href="#tab3" tabindex="-1">TAB 3</a>
    </paper-tab>
</paper-tabs>

<iron-pages selected="{{selected}}">
    <div>CONTENT OF PAGE 1</div>
    <div>CONTENT OF PAGE 2</div>
    <div>CONTENT OF PAGE 3</div>
</iron-pages>

侧-一个bar.html

<div class="drawer-content vertical layout" id="drawer">

      <div class="userItemInfo horizontal layout">
        <img id="avatar" class="userAvatar" src="../images/hipster.png" slot="item-icon"></img> 
        <div class="userDetails vertical layout" id="userDetails">
          <div class=username>USERNAME</div>
          <div class="subheader">further function</div>
        </div>
      </div>

      <paper-icon-item on-click="{{homePage}}">
        <iron-icon icon="home" slot="item-icon"></iron-icon> <span>Home</span>
      </paper-icon-item>
      <paper-icon-item on-click="{{expertPage}}">
        <iron-icon icon="done" slot="item-icon"></iron-icon> <span>Expert</span>
      </paper-icon-item>
      <paper-icon-item on-click="{{searchBar}}">
        <iron-icon icon="search" slot="item-icon"></iron-icon> <span>Search</span>
      </paper-icon-item>
      <paper-icon-item on-click="{{adminPage}}">
        <iron-icon icon="supervisor-account" slot="item-icon"></iron-icon> <span>Admin</span>
      </paper-icon-item>
      <div class="flex"></div> <!-- THIS IS THE ONLY WAY THAT I COULD GET THE LAST ENTRY TO BE FLEXED TO THE BOTTOM -->
      <paper-icon-item on-click="{{settingsPage}}">
        <iron-icon icon="settings" slot="item-icon"></iron-icon> <span id="">Settings</span>
      </paper-icon-item>

    </div>

感谢任何帮助。

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用<iron-pages>管理标签页,例如

<iron-pages selected="[[page]]">
    <!-- Expert | 3 tabs -->
    <page-tabs-expert></page-tabs-expert>
    <!--- Admin | 4 tabs -->
    <page-tabs-admin></page-tabs-admin>
    <!-- etc. -->
    <page-tabs-etc></page-tabs-etc>
</iron-pages>

并且,可以使用<iron-selector>https://www.webcomponents.org/element/PolymerElements/iron-selector

选择侧边栏
<iron-selector selected={{page}}>