我正在尝试将polymer-ui-tabs
组件用于传统标签组件,您可以根据选择的标签切换内容。除非我遗漏了某些内容,polymer-ui-tabs
组件似乎只提供了标签选择器位而没有用于切换内容的内置机制。这是对的吗?
如果没有,那么我该如何构建呢?我发现的最可能的事情是onPolymerSelect
polymer_selector
,但该方法目前看起来像这样
Stream<CustomEvent> get onPolymerSelect {
Element selection = $['selection'];
if(selection != null) {
// TODO return selection.onPolymerSelect;
}
}
我刚遇到http://kevmoo.github.io/widget.dart/#tabswidget,我会调查一下,但我想确保在拉入另一个图书馆之前我没有遗漏某些东西
答案 0 :(得分:1)
虽然它不在Dart中,但这里有一个示例,说明如何一起使用polymer-ui-tabs
和polymer-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>
如您所见,在选项卡元素和动画页面之间绑定当前选择允许您切换到选项卡所需的内容。