core-scaffold中的每个页面都有不同的工具栏



我目前使用core-scaffold作为我的基本应用程序结构。然而,我想有一个不同的工具栏为每个页面。我想做一些类似的事情:

<core-scaffold>
        <core-header-panel navigation flex mode="seamed">
            <core-toolbar>
                Veganolux
            </core-toolbar>
            <core-menu>
                <paper-item icon="store" label="Restaurants" on-tap="{{showRestaurants}}"></paper-item>
                <paper-item icon="settings" label="Settings" on-tap="{{showSettings}}"></paper-item>
                <paper-item icon="info" label="About" on-click="{{showAbout}}"></paper-item>
            </core-menu>
        </core-header-panel>
        <div tool>Restaurants</div>
        <core-pages id="pages" selected="0">
            <section id="pageRestaurants">
                <div tool>Toolbar with buttons</div>
            </section>
            <section id="pageSettings">
                <div tool>Toolbar without buttons</div>
            </section>
            <section id="pageAbout">
                <div tool>Toolbar with other buttons</div>
            </section>
        </core-pages>
    </core-scaffold>

这是不可能的,因为它不是core-scaffold的直接子节点。我知道我可以添加数据绑定来改变标题,但如果我添加不同的按钮等,就会变得很复杂。到工具栏

一个选项是创建一个activePage变量来保存当前选择的页面。您的on-tap事件处理程序将更新activePage变量。然后,您可以将core-header-panel的部分包装在<template if="{{ activePage === 'restaurants' }}">这样的条件模板中。

另一种选择是创建多个布局元素,并将页面元素包装在如下布局中http://erikringsmuth.github.io/app-router/#/layouts.

最新更新