1

我正在使用 page.js 编写一个聚合物单页网站,就像在聚合物入门套件中一样。我没有使用纸质菜单进行路由,而是使用纸质标签。

所以路由工作正常,但我不能让纸质标签看起来像纸质标签了。它们看起来像链接,我看不到底部的选择栏。

知道我做错了什么吗?

索引.html

<!-- Main Toolbar -->
    <paper-toolbar id="mainToolbar" class="medium-tall">
      <!-- Application name -->
      <div class="app-name">Website</div>

      <span class="space"></span>

      <!-- Toolbar icons -->
      <paper-icon-button icon="refresh"></paper-icon-button>
      <paper-icon-button icon="search"></paper-icon-button>

      <!-- Application tabs -->
      <paper-tabs class="bottom" attr-for-selected="data-route" selected="[[route]]">
        <paper-tab link>
          <a data-route="home" href="{{baseUrl}}">
            <iron-icon icon="home"></iron-icon>
            <span>Home</span>
          </a>
        </paper-tab>
        <paper-tab link>
          <a data-route="artist" href="{{baseUrl}}artist">
            <iron-icon icon="home"></iron-icon>
            <span>Artist</span>
          </a>
        </paper-tab>
        <paper-tab link>
          <a data-route="teacher" href="{{baseUrl}}teacher">
            <iron-icon icon="home"></iron-icon>
            <span>Teacher</span>
          </a>
        </paper-tab>
        <paper-tab link>
          <a data-route="research" href="{{baseUrl}}research">
            <iron-icon icon="home"></iron-icon>
            <span>Research</span>
          </a>
        </paper-tab>
        <paper-tab link>
          <a data-route="contact" href="{{baseUrl}}contact">
            <iron-icon icon="mail"></iron-icon>
            <span>Contact</span>
          </a>
        </paper-tab>
      </paper-tabs>
    </paper-toolbar>

    <!-- Main Content -->
    <div class="content">
      <iron-pages attr-for-selected="data-route" selected="{{route}}">
        <section data-route="home">
          <paper-material elevation="1">
            <my-greeting></my-greeting>

            <p class="subhead">You now have:</p>
            <my-list></my-list>

            <p>Looking for more Web App layouts? Check out our <a href="https://github.com/PolymerElements/app-layout-templates">layouts</a> collection. You can also <a href="http://polymerelements.github.io/app-layout-templates/">preview</a> them live.</p>
          </paper-material>
        </section>

        <section data-route="artist">
          <paper-material elevation="1">
            <h2 class="page-title">Users</h2>
            <p>This is the users section</p>
            <a href$="{{baseUrl}}users/Addy">Addy</a><br>
            <a href$="{{baseUrl}}users/Rob">Rob</a><br>
            <a href$="{{baseUrl}}users/Chuck">Chuck</a><br>
            <a href$="{{baseUrl}}users/Sam">Sam</a>
          </paper-material>
        </section>

        <section data-route="teacher">
          <paper-material elevation="1">
            <h2 class="page-title">User: {{params.name}}</h2>
            <div>This is {{params.name}}'s section</div>
          </paper-material>
        </section>

        <section data-route="contact">
          <paper-material elevation="1">
            <h2 class="page-title">Contact</h2>
            <p>This is the contact section</p>
          </paper-material>
        </section>
      </iron-pages>
    </div>
4

1 回答 1

1

我想我理解你的问题。当您单击选项卡时,它们不会保存单击和选定选项卡的状态。

这个答案将部分澄清问题Change URL in address bar after click on DOM element with javascript/jquery

在 Polymer 中我有同样的问题,但菜单项。我认为您可以通过以下方式解决它:

1)。使用app-router代替 page.js 并向其添加 pushstate 模式mode='pushstate'

2)。在包含 app-router 之前将 pushstate-anchor 包含到您的页面中<link rel="import" href="../bower_components/pushstate-anchor/pushstate-anchor.html">。这将保存所有链接并且不会重新加载页面。

于 2016-03-16T08:42:08.130 回答