1

我有这样的纸标签

<paper-dialog id="view">  
  <paper-tabs selected="0">
    <paper-tab on-tap="_changeList">TAB 1</paper-tab>
    <paper-tab on-tap="_changeList">TAB 2</paper-tab>
    <paper-tab on-tap="_changeList">TAB 3</paper-tab>
  </paper-tabs>
  <iron-list>some story for tab 1</iron-list>
  <iron-list>some story for tab 2</iron-list>
  <iron-list>some story for tab 3</iron-list>
 </paper-dialog>

每个标签我都有不同的熨斗列表。将选择第一个选项卡,但由于用户将单击其他选项卡,因此应更改所选选项卡的内容。_changeList 函数会带来不同的数据。我该如何实现呢?请

4

1 回答 1

1

paper-tabs通过将'的属性selectediron-pages' 的属性绑定,selected将显示基于所选选项卡的对应关系。

<paper-dialog id="view">
   <paper-tabs selected="{{currentPage}}">
      <paper-tab on-tap="_changeList">TAB 1</paper-tab>
      <paper-tab on-tap="_changeList">TAB 2</paper-tab>
      <paper-tab on-tap="_changeList">TAB 3</paper-tab>
   </paper-tabs>
   <iron-pages selected="{{currentPage}}">
      <iron-list>some story for tab 1</iron-list>
      <iron-list>some story for tab 2</iron-list>
      <iron-list>some story for tab 3</iron-list>
   </iron-pages>
</paper-dialog>

由于您想通过默认值显示第一个选项卡,您需要将currentPage值设置为0

ready: function(){
    this.currentPage = 0;
}

希望这可以帮助 :)

于 2017-06-16T10:53:29.387 回答