【问题标题】:Switching content when tab selected using polymer ui elements tabs使用聚合物 ui 元素选项卡选择选项卡时切换内容
【发布时间】:2014-09-13 17:03:47
【问题描述】:

我正在尝试将polymer-ui-tabs 组件用于传统选项卡组件,您可以在其中根据选择的选项卡切换内容。除非我遗漏了一些东西,否则polymer-ui-tabs 组件似乎只提供选项卡选择器位,而没有用于切换内容的内置机制。对吗?

如果没有,那么我该如何在它之上构建它?我发现的最有可能的是onPolymerSelect in polymer_selector 但该方法目前看起来像这样

Stream<CustomEvent> get onPolymerSelect {
  Element selection = $['selection'];
  if(selection != null) {
    // TODO return selection.onPolymerSelect;
  }
}

我刚刚遇到了http://kevmoo.github.io/widget.dart/#tabswidget,我将对其进行研究,但只是想确保在我拉入另一个库之前我没有遗漏任何东西

【问题讨论】:

  • 我将 polymer-ui-tab 移植到 Dart 但我自己还没有使用过。我在这里找到了一个例子groups.google.com/forum/#!topic/polymer-dev/QYe4TKR40EY。 polymer-ui-animated-pages 尚未移植,但 polymer-ui-pages 已移植。它的用法可能相似。
  • 感谢@GünterZöchbauer。我想我明白了。很快就会试一试。实际上它看起来真的很酷。简单但非常灵活,这正是我所需要的,因为它最终看起来与普通选项卡完全不同,并且可能会在侧面,这应该很容易通过网格布局实现

标签: dart dart-polymer polymer


【解决方案1】:

虽然它不在 Dart 中,但这里有一个示例,说明如何同时使用 polymer-ui-tabspolymer-ui-animated-pages 来达到预期的效果 (demo):

index.html:

<!-- <script src="platform.js"></script>
     not necessary anymore with Polymer >= 0.14.0 -->
<script src="packages/web_components/dart_support.js"></script>

<link rel="import" href="s-app.html">
<s-app></s-app>

s-app.html:

<link rel="import" href="polymer.html">
<link rel="import" href="polymer-ui-tabs/polymer-ui-tabs.html">
<link rel="import" href="polymer-ui-animated-pages/polymer-ui-animated-pages.html">
<link rel="import" href="polymer-flex-layout/polymer-flex-layout.html">

<polymer-element name="s-app">  
  <template>
    <style>
      :host {
        display: block;
      }
      polymer-ui-tabs {
        border-top: 1px solid #000;
      }
      polymer-ui-tabs > * {
        border-right: 1px solid #000;
      }
      header {
        padding: 10px;
        background: black;
        color: white;
      }
      polymer-ui-animated-pages > * {
        padding: 10px;
      }

    </style>
    <polymer-flex-layout vertical></polymer-flex-layout>
    <header>
      Header
    </header>
    <polymer-ui-animated-pages selected="{{page}}" flex>
      <div>Page One</div>
      <div>Page Two</div>
      <div>Page Three</div>
    </polymer-ui-animated-pages>
    <polymer-ui-tabs selected="{{page}}">
      <span flex>One</span>
      <span flex>Two</span>
      <span flex>Three</span>
    </polymer-ui-tabs>
  </template>

  <script>
    // switch page on tab
    Polymer('s-app', {page:0});
  </script>

</polymer-element>

如您所见,在选项卡元素和动画页面之间绑定当前选择允许您切换到选项卡所需的内容。

【讨论】:

  • 感谢您的示例,但不幸的是,polymer-ui-animated-pages 尚未移植到 Dart。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-25
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-15
相关资源
最近更新 更多