Top App Bar

Top App Bar充当应用程序标题,导航图标和操作项等项目的容器。

使用

方法1:

  1. <m-top-app-bar adjust dense fixed
  2. heading='Omim'
  3. navigations="['favorite']"
  4. action-items="[{text: 'Omim'}, 'favorite_border', 'favorite_border']"
  5. ></m-top-app-bar>

方法2 (导航按钮自定义任意元素):

  1. <m-top-app-bar
  2. heading='Click to view all menus'
  3. adjust>
  4. <navigation>
  5. <m-avatar icon="person" background-color='#FFF' color='#0072d9' />
  6. </navigation>
  7. <actionitem>
  8. <m-badge css="..." content="99">
  9. <m-icon path="..." color="#FFF" />
  10. </m-badge>
  11. </actionitem>
  12. <div style='width:100%'>
  13. <m-tab css={`.mdc-tab-bar {background: #EEE;}`} default-active='speed' align="end" stacked>
  14. <item label="Recents" value="speed" icon="access_time"></item>
  15. <item label="Nearby" value="fire" icon="near_me"></item>
  16. <item label="Favorites" value="lol" icon="favorite"></item>
  17. </m-tab>
  18. </div>
  19. </m-top-app-bar>

Omi 中使用

JSX:

方法1:

  1. <m-top-app-bar adjust dense fixed
  2. heading='Omim'
  3. navigations={['favorite']}
  4. action-items={[{text: 'Omim'}, 'favorite_border', 'favorite_border']}
  5. onNavigation={this.onMenu}
  6. onAction={this.onMenu}
  7. />

方法2 (导航按钮自定义任意元素):

  1. <m-top-app-bar
  2. heading={'Click to show menus' + this.titleOmi}
  3. scroll-target={this.scrollTarget}
  4. onNavigation={this.onDemoStart}
  5. onAction={this.onMenuStart}>
  6. <navigation>
  7. <m-avatar icon="person" backgroundColor='#FFF' color={this.themeColor} />
  8. </navigation>
  9. <actionitem>
  10. <m-badge css={`...`} content="99">
  11. <m-icon path="..." color="#FFF" />
  12. </m-badge>
  13. </actionitem>
  14. </m-top-app-bar>

API

Props

NameTypeDefaultsDetails
headingstring标题内容
shortboolean带有缩短动动画
shortCollapsedboolean固定为缩短状态
prominentboolean突出显示标题
denseboolean更紧凑的顶部应用栏
fixedboolean固定顶部应用栏
adjustboolean自动填充顶部应用栏高度
bottomboolean底部应用栏
navigationsobject左侧导航按钮
actionItemsobject右侧按钮
scrollTargetEventTargetwindow设置目标滚动条(JSX 使用)
scrollTargetIdstringwindow设置目标滚动条(原生 js 使用)
onNavigationfunction单击左侧导航栏触发
onActionfunction单击右侧按钮触发