重新加载时的聚合物错误 [英] polymer error on reloading
问题描述
我已经安装了聚合物入门工具包,一旦我加载了该入门工具包,所有东西都已正确加载,并且网址看起来像 http ://127.0.0.1:8887/,然后,当我单击任意视图时,该页面就会打开,并且网址更改为 http://127.0.0.1:8887/view1 ,但是如果我现在重新加载浏览器,而不是显示同一页面,它会显示未找到条目错误.我曾尝试通过Internet搜索解决方案,但我没有找不到.我该怎么办才能解决它.
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 view that page gets open and url changes to http://127.0.0.1:8887/view1 but if i reload the browser now, instead of showing the same page it displays the entry not found error.i have tried searching over internet for solution but i didn't find one.what should i do to fix it.
推荐答案
刷新页面时( http://127.0.0.1:8887/view1 ),您请求服务器提供view1
资源,但服务器找不到该资源,因为没有.该路径(.../view1
)仅由聚合物应用本身而非服务器识别.
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.
尝试在路径中使用哈希.将use-hash-as-path
属性添加到主页内的app-location
元素中.
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>
编辑
仅添加use-hash-as-path
属性是不够的.您还需要在菜单项中稍微更改href
.
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"
至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>
这篇关于重新加载时的聚合物错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!