PageHeader页头

页头用来声明页面的主题,包含了用户所关注的最重要的信息。

何时使用

当需要用户快速理解当前页面是什么以及它的功能时使用。

单独引入此组件

想要了解更多关于单独引入组件的内容,可以在快速上手页面进行查看。

  1. import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';

代码演示

PageHeader页头 - 图1

标准样式

标准页头

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-page-header-basic',
  4. template: `
  5. <nz-page-header (nzBack)="onBack()" nzBackIcon nzTitle="Title" nzSubtitle="This is a subtitle"> </nz-page-header>
  6. `,
  7. styles: [
  8. `
  9. nz-page-header {
  10. border: 1px solid rgb(235, 237, 240);
  11. }
  12. `
  13. ]
  14. })
  15. export class NzDemoPageHeaderBasicComponent {
  16. onBack() {
  17. console.log('onBack');
  18. }
  19. }

PageHeader页头 - 图2

带面包屑页头

带面包屑页头

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-page-header-breadcrumb',
  4. template: `
  5. <nz-page-header nzBackIcon nzTitle="Title">
  6. <nz-breadcrumb nz-page-header-breadcrumb>
  7. <nz-breadcrumb-item>First-level Menu</nz-breadcrumb-item>
  8. <nz-breadcrumb-item>
  9. <a>Second-level Menu</a>
  10. </nz-breadcrumb-item>
  11. <nz-breadcrumb-item>Third-level Menu</nz-breadcrumb-item>
  12. </nz-breadcrumb>
  13. </nz-page-header>
  14. `,
  15. styles: [
  16. `
  17. nz-page-header {
  18. border: 1px solid rgb(235, 237, 240);
  19. }
  20. `
  21. ]
  22. })
  23. export class NzDemoPageHeaderBreadcrumbComponent {}

PageHeader页头 - 图3

内容

你可以使用 <nz-page-header-content> 添加内容。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-page-header-content',
  4. template: `
  5. <nz-page-header nzTitle="Page Title">
  6. <nz-breadcrumb nz-page-header-breadcrumb>
  7. <nz-breadcrumb-item>First-level Menu</nz-breadcrumb-item>
  8. <nz-breadcrumb-item>
  9. <a>Second-level Menu</a>
  10. </nz-breadcrumb-item>
  11. <nz-breadcrumb-item>Third-level Menu</nz-breadcrumb-item>
  12. </nz-breadcrumb>
  13. <nz-page-header-content>
  14. <div class="wrap">
  15. <div class="content">
  16. <div class="content">
  17. <p>
  18. Ant Design interprets the color system into two levels: a system-level color system and a product-level
  19. color system.
  20. </p>
  21. <p>
  22. Ant Design's design team preferred to design with the HSB color model, which makes it easier for
  23. designers to have a clear psychological expectation of color when adjusting colors, as well as
  24. facilitate communication in teams.
  25. </p>
  26. <p class="content-link">
  27. <a>
  28. <img src="https://gw.alipayobjects.com/zos/rmsportal/MjEImQtenlyueSmVEfUD.svg" alt="start" />Quick
  29. Start
  30. </a>
  31. <a>
  32. <img src="https://gw.alipayobjects.com/zos/rmsportal/NbuDUAuBlIApFuDvWiND.svg" alt="info" />Product
  33. Info
  34. </a>
  35. <a>
  36. <img src="https://gw.alipayobjects.com/zos/rmsportal/ohOEPSYdDTNnyMbGuyLb.svg" alt="doc" />Product Doc
  37. </a>
  38. </p>
  39. </div>
  40. </div>
  41. <div class="extra-content">
  42. <img
  43. src="https://gw.alipayobjects.com/mdn/mpaas_user/afts/img/A*KsfVQbuLRlYAAAAAAAAAAABjAQAAAQ/original"
  44. alt="content"
  45. />
  46. </div>
  47. </div>
  48. </nz-page-header-content>
  49. </nz-page-header>
  50. `,
  51. styles: [
  52. `
  53. nz-page-header {
  54. border: 1px solid rgb(235, 237, 240);
  55. }
  56. .wrap {
  57. display: flex;
  58. }
  59. .content {
  60. flex: 1;
  61. }
  62. .content p {
  63. margin-bottom: 8px;
  64. }
  65. .content-link {
  66. padding-top: 16px;
  67. }
  68. .content-link a {
  69. display: inline-block;
  70. vertical-align: text-top;
  71. margin-right: 32px;
  72. }
  73. .content-link a img {
  74. margin-right: 8px;
  75. }
  76. .extra-content {
  77. min-width: 240px;
  78. text-align: right;
  79. }
  80. `
  81. ]
  82. })
  83. export class NzDemoPageHeaderContentComponent {}

PageHeader页头 - 图4

复杂的例子

使用操作区,并自定义子节点

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-page-header-actions',
  4. template: `
  5. <nz-page-header nzBackIcon>
  6. <nz-page-header-title>Title</nz-page-header-title>
  7. <nz-page-header-subtitle>This is a subtitle</nz-page-header-subtitle>
  8. <nz-page-header-tags>
  9. <nz-tag [nzColor]="'red'">Warning</nz-tag>
  10. </nz-page-header-tags>
  11. <nz-page-header-extra>
  12. <button nz-button>Operation</button>
  13. <button nz-button>Operation</button>
  14. <button nz-button nzType="primary">Primary</button>
  15. </nz-page-header-extra>
  16. <nz-page-header-content>
  17. <div class="wrap">
  18. <div nz-row class="content padding">
  19. <div nz-col nzSpan="12">
  20. <div class="description">
  21. <span class="term">Created</span>
  22. <p class="detail">Lili Qu</p>
  23. </div>
  24. </div>
  25. <div nz-col nzSpan="12">
  26. <div class="description">
  27. <span class="term">Association</span>
  28. <a>421421</a>
  29. </div>
  30. </div>
  31. <div nz-col nzSpan="12">
  32. <div class="description">
  33. <span class="term">Creation Time</span>
  34. <p class="detail">2017-01-10</p>
  35. </div>
  36. </div>
  37. <div nz-col nzSpan="12">
  38. <div class="description">
  39. <span class="term">Effective Time</span>
  40. <p class="detail">2017-01-10</p>
  41. </div>
  42. </div>
  43. <div nz-col nzSpan="12">
  44. <div class="description">
  45. <span class="term">Remarks</span>
  46. <p class="detail">Gonghu Road, Xihu District, Hangzhou, Zhejiang, China</p>
  47. </div>
  48. </div>
  49. </div>
  50. <div nz-row class="extra-content">
  51. <div nz-col nzSpan="12">
  52. <span class="label">Status</span>
  53. <p class="detail">Pending</p>
  54. </div>
  55. <div nz-col nzSpan="12">
  56. <span class="label"> Price</span>
  57. <p class="detail">$ 568.08</p>
  58. </div>
  59. </div>
  60. </div>
  61. </nz-page-header-content>
  62. <nz-page-header-footer>
  63. <nz-tabset [nzSelectedIndex]="1">
  64. <nz-tab nzTitle="Details"></nz-tab>
  65. <nz-tab nzTitle="Rule"></nz-tab>
  66. </nz-tabset>
  67. </nz-page-header-footer>
  68. </nz-page-header>
  69. `,
  70. styles: [
  71. `
  72. nz-page-header {
  73. border: 1px solid rgb(235, 237, 240);
  74. }
  75. .wrap {
  76. display: flex;
  77. }
  78. .content {
  79. flex: 1;
  80. }
  81. .content.padding {
  82. padding-left: 40px;
  83. }
  84. .content p {
  85. margin-bottom: 8px;
  86. }
  87. .content .description {
  88. display: table;
  89. }
  90. .description .term {
  91. display: table-cell;
  92. margin-right: 8px;
  93. padding-bottom: 8px;
  94. white-space: nowrap;
  95. line-height: 20px;
  96. }
  97. .description .term:after {
  98. position: relative;
  99. top: -0.5px;
  100. margin: 0 8px 0 2px;
  101. content: ':';
  102. }
  103. .description .detail {
  104. display: table-cell;
  105. padding-bottom: 8px;
  106. width: 100%;
  107. line-height: 20px;
  108. }
  109. .extra-content {
  110. min-width: 240px;
  111. text-align: right;
  112. }
  113. .extra-content .label {
  114. font-size: 14px;
  115. color: rgba(0, 0, 0, 0.45);
  116. line-height: 22px;
  117. }
  118. .extra-content .detail {
  119. font-size: 20px;
  120. color: rgba(0, 0, 0, 0.85);
  121. line-height: 28px;
  122. }
  123. `
  124. ]
  125. })
  126. export class NzDemoPageHeaderActionsComponent {}

API

  1. <nz-page-header nzTitle="Page Title"></nz-page-header>

nz-page-headercomponent

参数说明类型默认值
[nzTitle]title 文字string | TemplateRef<void>-
[nzSubtitle]subTitle 文字string | TemplateRef<void>-
[nzBackIcon]自定义 back iconstring | TemplateRef<void>-
(nzBack)返回按钮的点击事件EventEmitter<void>未订阅该事件时默认调用 Location[back]

Page header 组成部分

元素说明
<nz-page-header-title>title 部分,[nzTitle] 优先级更高
<nz-page-header-subtitle>subtitle 部分,[nzSubtitle] 优先级更高
<nz-page-header-content>内容部分
<nz-page-header-footer>底部部分
<nz-page-header-tags>title 旁的 tag 列表容器
<nz-page-header-extra>title 的行尾操作区部分
<nz-breadcrumb nz-page-header-breadcrumb>面包屑部分