如何通过单击纸标签来更改页面内容?

How to change page content by click over paper-tab?

我有这样的纸标签

<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>

我为每个选项卡准备了不同的 iron-list。第一个选项卡将是 select,但由于用户将单击其他选项卡,因此应更改 selected 选项卡的内容。 _changeList 函数会带来不同的数据。我怎样才能做到这一点?请

通过绑定 paper-tabsselected 属性与 iron-pagesselected 属性 将根据所选选项卡显示相应的内容。

<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;
}

希望这对您有所帮助:)