Templating in Polymer: How to load components into a specific layout

二次信任 提交于 2019-12-03 17:09:23

You're looking for the <content> tag. Check out how this works.

simple-layout.html

<polymer-element name="simple-layout" noscript>
  <template>
    <core-drawer-panel>
      <core-header-panel drawer>
        <content select=".title"><!-- content with class 'title' --></content>
      </core-header-panel>
      <core-header-panel content>
        <core-toolbar main></core-toolbar>
        <content><!-- all other content will show up here --></content>
      </core-header-panel>
    </core-drawer-panel>
  </template>
</polymer-element>

home-page.html

<link rel="import" href="simple-layout.html">
<polymer-element name="home-page" noscript>
  <template>
    <simple-layout>

      <div class="title">Home</div>

      <h1>This contents is loaded into the main part of the layout.</h1>
      <p>Yada yada yada. More content in the main layout.</p>

    </simple-layout>
  </template>
</polymer-element>

This way you can load a "page" element and it will include the layout it wants to use.

http://erikringsmuth.github.io/app-router/#/layouts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!