我正在努力找出一些基本路线。我使用的是聚合物1.5.0,我在使用嵌套路由时遇到了问题。
我使用的是应用程序路由0.9.2
作为这篇文章暗示,聚合物在路由过程中采用分散的方法。因此,我决定做以下工作:
<app-route route="{{route}}"
pattern="/:page"
data="{{data}}"
tail="{{tail}}">
</app-route>
<iron-pages selected="{{data.page}}" attr-for-selected="title" fallback-selection="404">
<pgarena-home-app title="" route="{{tail}}" ></pgarena-home-app>
<pgarena-tournament-app title="tournament" route="{{tail}}"></pgarena-tournament-app>
<pgarena-account-app title="account" route="{{tail}}"></pgarena-account-app>
<div title="404">
<h1>{{data.page}} could not be found!</h1>
</div>
</iron-pages> 子页面:
pgarena-帐户-应用程序
<iron-pages selected="{{data.action}}" attr-for-selected="title" fallback-selection="404">
<pgarena-account-index-view title=""></pgarena-account-index-view>
<pgarena-account-login-view title="login"></pgarena-account-login-view>
<pgarena-account-register-view title="register"></pgarena-account-register-view>
<div title="404">
<h1>Not found :(</h1>
</div>
</iron-pages>pgarena-锦标赛-应用
<!-- Chooses the new tournament page. -->
<app-route
route="{{route}}"
pattern="/:action"
data="{{data}}"
tail="{{tail}}"
>
</app-route>
<iron-pages selected="{{data.action}}" attr-for-selected="title" fallback-selection="404">
<pgarena-tournament-index-view title=""></pgarena-tournament-index-view>
<!-- The list of all the tournaments -->
<pgarena-tournament-list-view title="list"></pgarena-tournament-list-view>
<div title="404">
<h1>Not Found!</h1>
</div>
</iron-pages>一切看起来都很好,对吧?根据URL,我在这里所做的是利用延迟加载的元素。
我在多播实例中看到他们使用了“隐藏”方法。在其中他们选择元素。问题是我们失去了“延迟装载优势”。
有什么不对的?
发布于 2016-07-27 20:34:43
天哪!我完全忘了。在Polycast #46/47中 Rob Dodson使非常强调,当我们使用铁选择器时,我们应该传递单向绑定,即带有方括号[]的单向绑定,而花括号{}则是这样的。
所以在最后一天,应该是
<iron-pages selected="[[data.action]]"而不是:
<iron-pages selected="{{data.action}}"https://stackoverflow.com/questions/38622697
复制相似问题