1

我正在开发一个带有 spring-boot 的聚合物 webApp,到目前为止,我确实喜欢两个单独的应用程序,因为我不知道如何从一个选项卡导航到另一个选项卡,我真的很想合并两个我不知道的应用程序请不要介意有导航按钮。

正如您在第一张图片中看到的那样,有一些标签我想在它们之间导航,例如应用程序标签会将我带到另一张图片中的应用程序。我在网上搜索了很多,但我能找到的只是如何在静态内容之间导航。

这是第一个应用程序 在此处输入图像描述

及其来源

在此处输入图像描述

这是另一个应用程序

在此处输入图像描述

及其来源

在此处输入图像描述

4

1 回答 1

3

您可以使用 app-route 组件。 https://elements.polymer-project.org/elements/app-route

这是关于应用程序路由的多播。 https://www.youtube.com/watch?v=iAgSvlYavX0&list=PLOU2XLYxmsII5c3Mgw6fNYCzaWrsM3sMN&index=2

基本上,您将使用 route 和 page 属性来设置处于活动状态的路由。将使用铁选择器组件在激活的代码段之间进行切换。

像这样的东西:

<app-location route="{{ route }}"></app-location>
<app-route route="{{ route }}"
           pattern="/:page"
           data="{{ routeData }}"
           tail="{{ subroute }}"></app-route>

<iron-selector attr-for-selected="route"
               selected="[[ page ]]"
               role="navigation">
    <a route="editor" href="/editor">Editor</a>
    <a route="analyze" href="/analyze">Analyze</a>
    <a route="community" href="/community">Community</a>
</iron-selector>

<iron-pages role="main"
            attr-for-selected="route"
            selected="[[ page ]]">
    <my-editor route="editor"></my-editor>
    <my-analyze route="analyze"></my-analyze>
    <my-community route="community"></my-community>
</iron-pages>

<script>
     Polymer({ 
         is:'my-element',
         properties: {
             page: {
                 type: String,
                 notify: true,
                 reflectToAttribute: true,
                 observer: "_pageChanged"
             }
         },

         observers: [
             "_routePageChanged(routeData.page)"
         ],

         attached: function(e) {
             // Lazyload the views as soon as the AppShell has been Painted
             this.importHref(
                 this.resolveUrl("my-editor.html"), null, null, true);
             this.importHref(
                 this.resolveUrl("my-analyze"), null, null, true);
             this.importHref(
                 this.resolveUrl("my-community"), null, null, true);

             // If the application is reloaded, redirect to /analyze
             if(this.page != "analyze"){
                 this.set("route.path", "/analyze");
             }
         },

         _changeRoute: function(e) {
             this.set("route.path", e.detail.requestRoute);
         },

         _routePageChanged: function(page) {
             this.page = page || "analyze";
         },
     })
</script>
于 2016-08-09T17:40:10.663 回答