简体   繁体   English

聚合物1.0路线未渲染

[英]polymer 1.0 route not rendering

I am trying to get a route to work on a project that has been created using the polymer starter kit .Other routes work but I have been having issues with a nested route that I have been trying to implement 我正在尝试为在使用聚合物入门工具包创建的项目上工作的路线工作。其他路线也可行,但是我一直在尝试实现的嵌套路线存在问题

I want to be able to add a route /boat/add and point it to it's respective element. 我希望能够添加一条路线/boat/add并将其指向相应的元素。 I started out by adding the following code to the routing.html file which is running the page.js router. 我首先将以下代码添加到运行page.js路由器的routing.html文件中。

page('/boat/add', function() {
        app.route = 'boat-add';
        setFocus(app.route);
    });

This ofcourse is inside the WebComponentsReady event listener. 当然,这是在WebComponentsReady事件侦听器内部。

Next, I have imported the element into the main index.html file under the template tag 接下来,我已将元素导入模板标签下的主index.html文件中

<!-- Main Content -->
        <div class="content">
            <iron-pages attr-for-selected="data-route" selected="{{route}}">                
                <section data-route="boat/add" tabindex="-1">
                    <bw-boat-add></bw-boat-add>
                </section>                  
            </iron-pages>
        </div>
    </paper-scroll-header-panel>
</paper-drawer-panel>
</template>

and here is the actual template file 这是实际的模板文件

<dom-module is="bw-boat-add">
  <template>
        Test
  </template>
  <script>
        (function() {
          "use strict";

           Polymer({
                is: 'bw-boat-add',
                attached: function() {
                  console.log(1);
                }
           });

        })();
  </script>
</dom-module>

Also, if it is worth it, the attached method handler function returns a 1 in the console. 另外,如果值得,附加的方法处理函数在控制台中返回1。 Is there something else I am missing. 还有其他我想念的东西吗?

In your iron-pages you set data-route to boat/add instead of boat-add . iron-pages ,将data-route设置为boat / add,而不是boat-add You probably need to change this to: 您可能需要将其更改为:

<section data-route="boat-add" tabindex="-1">
    <bw-boat-add></bw-boat-add>
</section>                

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM