polymer error on reloading

后端 未结 1 1219
抹茶落季
抹茶落季 2021-01-25 15:25

i have installed the polymer starter kit and once i load the starter kit every thing gets loaded properly and the url looks like http://127.0.0.1:8887/ then once i click on any

相关标签:
1条回答
  • 2021-01-25 15:47

    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>
    
    0 讨论(0)
提交回复
热议问题