应用程序路由器导航不工作



我有一个简单的设置:

索引:

<app-router>
    <app-route path="/home" element="home-element" bindRouter></app-route>
    <app-route path="/test"  element="test-element" bindRouter></app-route>
</app-router>

测试元件:

<dom-module id="test-element">
    <template >
        <a href="#/home">Home</a>
    </template>
    <script>
        addEventListener('WebComponentsReady', function() {
            Polymer({
                is: "test-element"
            });
        });
    </script>
</dom-module>

家元素只是说"你好世界"我的问题是网址得到了更新,但页面没有改变。此外,当我直接在浏览器中键入任何url时,我需要点击两次"输入",以强制其刷新,使其正常工作。

这是个虫子吗?应用程序控制器无法使用聚合物1.x?还是我做错了什么?

对于最新发布的Polymer,您可以使用dna路由器。它适用于Polymer 1.x。您只能在HTML中定义状态、路线和视图。

对于状态

<dna-new-state state='home' route='/home/:id'></dna-new-state>

对于视图

<dna-view
state='home'
element='home-template'></dna-view>

有关更多信息,请访问:https://github.com/Saquib764/dna-router

享受:)

最新更新