036_PageHeader页头

本文介绍了如何在前端项目中使用Element UI的PageHeader组件,通过实例演示了其在简单路径场景下的优势,并展示了如何配置和使用它的属性、事件和slot。跟随步骤创建一个带有事件处理的PageHeader组件,提升页面头部的易用性和信息呈现效率。

1. PageHeader页头

1.1. 如果页面的路径比较简单, 推荐使用页头组件而非面包屑组件。

1.2. Attributes

参数

说明

类型

可选值

默认值

title

标题

string

返回

content

内容

string

1.3. Events

事件名称

说明

回调参数

back

点击左侧区域触发

1.4. Slots

事件名称

说明

title

标题内容

content

内容

2. PageHeader页头例子

2.1. 使用脚手架新建一个名为element-ui-pageheader的前端项目, 同时安装Element插件。

2.2. 在components下创建PageHeader.vue 

<template>
  <div>
    <h1>基础</h1>
    <h4>如果页面的路径比较简单, 推荐使用页头组件而非面包屑组件。</h4>
    <el-page-header @back="goBack" content="详情页面"></el-page-header>
  </div>
</template>

<script>
export default {
  methods: {
    goBack () {
      console.log('go back')
    }
  }
}
</script>

2.3. 运行项目, 访问http://localhost:8080/#/PageHeader

/* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20250404 (32-bit version) * Copyright (c) 2000 - 2025 Intel Corporation * * Disassembly of E:/EFI/OC/ACPI/DMAR.aml * * ACPI Data Table [DMAR] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue (in hex) */ [000h 0000 004h] Signature : "DMAR" [DMA Remapping Table] [004h 0004 004h] Table Length : 00000050 [008h 0008 001h] Revision : 01 [009h 0009 001h] Checksum : 40 [00Ah 0010 006h] Oem ID : "INTEL " [010h 0016 008h] Oem Table ID : "EDK2 " [018h 0024 004h] Oem Revision : 00000002 [01Ch 0028 004h] Asl Compiler ID : "INTL" [020h 0032 004h] Asl Compiler Revision : 20250404 [024h 0036 001h] Host Address Width : 26 [025h 0037 001h] Flags : 01 [026h 0038 00Ah] Reserved : 00 00 00 00 00 00 00 00 00 00 [030h 0048 002h] Subtable Type : 0000 [Hardware Unit Definition] [032h 0050 002h] Length : 0020 [034h 0052 001h] Flags : 01 [035h 0053 001h] Size (decoded below) : 00 Size (pages, log2) : 0 [036h 0054 002h] PCI Segment Number : 0000 [038h 0056 008h] Register Base Address : 0000000000D00000 [040h 0064 001h] Device Scope Type : 03 [IOAPIC Device] [041h 0065 001h] Entry Length : 08 [042h 0066 001h] Flags : 00 [043h 0067 001h] Reserved : 00 [044h 0068 001h] Enumeration ID : 02 [045h 0069 001h] PCI Bus Number : 00 [046h 0070 002h] PCI Path : 1E,07 [048h 0072 001h] Device Scope Type : 04 [Message-capable HPET Device] [049h 0073 001h] Entry Length : 08 [04Ah 0074 001h] Flags : 00 [04Bh 0075 001h] Reserved : 00 [04Ch 0076 001h] Enumeration ID : 00 [04Dh 0077 001h] PCI Bus Number : 00 [04Eh 0078 002h] PCI Path : 1E,06 Raw Table Data: Length 80 (0x50) 0000: 44 4D 41 52 50 00 00 00 01 40 49 4E 54 45 4C 20 // DMARP....^INTEL 0010: 45 44 4B 32 20 20 20 20 02 00 00 00 49 4E 54 4C // EDK2 ....INTL 0020: 04 04 25 20 26 01 00 00 00 00 00 00 00 00 00 00 // ..% &........... 0030: 00 00 20 00 01 00 00 00 00 00 D0 00 00 00 00 00 // .. ............. 0040: 03 08 00 00 02 00 1E 07 04 08 00 00 00 00 1E 06 // ................
08-30
VueElement UI 框架中,`PageHeader` 组件提供了一个用于展示面标题和导航的界面元素,同时支持通过 `slots` 插槽来自定义内容。插槽的使用可以增强组件的灵活性和可定制性,允许开发者插入自定义的 HTML 或 Vue 组件。 ### 默认插槽 `PageHeader` 组件支持默认插槽,用于在区域插入自定义内容。例如,可以在中添加额外的操作按钮或信息提示。 ```html <el-page-header> <template #default> <div>这是自定义的内容</div> </template> </el-page-header> ``` ### 具名插槽 除了默认插槽,`PageHeader` 还提供了一些具名插槽,例如 `title` 和 `content`,这些插槽分别用于自定义标题和内容区域。 - `title` 插槽用于自定义标题部分。 - `content` 插槽用于自定义主要内容部分。 ```html <el-page-header> <template #title> <h1>自定义标题</h1> </template> <template #content> <span>这里是额外的内容</span> </template> </el-page-header> ``` 通过这些插槽的使用,开发者可以根据具体需求灵活地调整 `PageHeader` 的外观和功能,从而更好地融入到应用程序的整体设计中。 ### 示例代码 以下是一个完整的示例,展示了如何在实际项目中使用 `PageHeader` 的插槽功能: ```html <template> <el-page-header> <template #title> <h1>自定义标题</h1> </template> <template #content> <span>这里是额外的内容</span> </template> <template #default> <div>这是默认插槽的内容</div> </template> </el-page-header> </template> <script> export default { name: 'CustomPageHeader' } </script> ``` 通过上述方式,可以充分利用 `PageHeader` 组件的插槽特性来创建更加丰富和个性化的用户界面。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值