polymer error on reloading

旧时模样 提交于 2019-12-02 04:47:43

When you refresh the page (http://127.0.0.1:8887/view1) you request the view1 resource from the server, but the server can't find it because there isn't. That path (.../view1) is only recognized by the polymer app itself and not the server.

Try using hash in the path. Add the use-hash-as-path attribute to your app-location element inside the main page.

So, it should look like this:

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

EDIT

It is not enough to add the use-hash-as-path property. You will also need to change slightly the href in the menu items.

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

The code with more details:

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!