【问题标题】:app-router navigate not working应用路由器导航不起作用
【发布时间】:2015-11-01 04:43:27
【问题描述】:

我有这个简单的设置:

索引:

<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>

home-element 只是说“hello world” 我的问题是 url 得到更新,但页面没有改变。此外,当我直接在浏览器中输入任何 url 时,我需要按两次“enter”以强制刷新以使其正常工作。

这是一个错误吗?应用程序控制器不适用于聚合物 1.x?还是我做错了什么?

【问题讨论】:

  • 我不得不编辑源代码

标签: url-routing polymer-1.0 hashchange


【解决方案1】:

对于最新的 Polymer 版本,您可以使用dna-router。它适用于 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

享受:)

【讨论】:

    猜你喜欢
    • 2016-04-24
    • 2018-09-04
    • 2017-04-06
    • 2018-07-04
    • 2019-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多