首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >聚合物嵌套的app路径映射不正确

聚合物嵌套的app路径映射不正确
EN

Stack Overflow用户
提问于 2016-07-27 20:34:43
回答 1查看 1.5K关注 0票数 3

我正在努力找出一些基本路线。我使用的是聚合物1.5.0,我在使用嵌套路由时遇到了问题。

我使用的是应用程序路由0.9.2

作为这篇文章暗示,聚合物在路由过程中采用分散的方法。因此,我决定做以下工作:

代码语言:javascript
复制
<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-帐户-应用程序

代码语言:javascript
复制
<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-锦标赛-应用

代码语言:javascript
复制
<!-- 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,我在这里所做的是利用延迟加载的元素。

我在多播实例中看到他们使用了“隐藏”方法。在其中他们选择元素。问题是我们失去了“延迟装载优势”。

有什么不对的?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-27 20:34:43

天哪!我完全忘了。在Polycast #46/47中 Rob Dodson使非常强调,当我们使用铁选择器时,我们应该传递单向绑定,即带有方括号[]单向绑定,而花括号{}则是这样的。

所以在最后一天,应该是

代码语言:javascript
复制
<iron-pages selected="[[data.action]]"

而不是:

代码语言:javascript
复制
<iron-pages selected="{{data.action}}"
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38622697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档