重新加载时出现聚合物错误

polymer error on reloading

我已经安装了 Polymer 初学者工具包,一旦我加载了初学者工具包,所有东西都会正确加载并且 url 看起来像 http://127.0.0.1:8887/ then once i click on any view that page gets open and url changes to http://127.0.0.1:8887/view1 但是如果我现在重新加载浏览器,而不是显示同一页面显示未找到条目 error.i 已尝试在互联网上搜索解决方案,但我没有找到 one.what 我应该如何修复它。

当您刷新页面 (http://127.0.0.1:8887/view1) 时,您向服务器请求 view1 资源,但服务器找不到它,因为没有。该路径 (.../view1) 只能被 Polymer 应用程序本身识别,而不能被服务器识别。

尝试在路径中使用散列。将 use-hash-as-path 属性添加到主页中的 app-location 元素。

所以,它应该是这样的:

<app-location route="{{route}}" use-hash-as-path></app-location>

编辑

还不够加use-hash-as-path属性。您还需要稍微更改菜单项中的 href

href="/view1"href="#/view1"

更详细的代码:

<app-location route="{{route}}" use-hash-as-path></app-location>
<app-route
    route="{{route}}"
    pattern="/:page"
    data="{{routeData}}"
    tail="{{subroute}}"></app-route>

<app-drawer-layout fullbleed>

  <!-- Drawer content -->
  <app-drawer>
    <app-toolbar>Menu</app-toolbar>
    <iron-selector selected="[[page]]" attr-for-selected="name" class="drawer-list" role="navigation">
      <a name="view1" href="#/view1">View One</a>
      <a name="view2" href="#/view2">View Two</a>
      <a name="view3" href="#/view3">View Three</a>
    </iron-selector>
  </app-drawer>
  ...
</app-drawer-layout>