elementui title
Element UI Title 组件使用指南
Element UI 的 Title 组件通常指代的是 Typography 文本组件中的标题样式,或对话框(Dialog)、卡片(Card)等组件中的标题部分。以下是具体使用方法:
对话框(Dialog)标题设置
在 Dialog 组件中,通过 title 属性直接设置标题:
<el-dialog title="提示标题" :visible.sync="dialogVisible">
内容区域
</el-dialog>
卡片(Card)标题设置
Card 组件支持通过 header 插槽自定义标题:
<el-card>
<div slot="header" class="clearfix">
<span>卡片标题</span>
<el-button style="float: right">操作按钮</el-button>
</div>
卡片内容
</el-card>
文本标题样式(Typography)
Element UI 未直接提供独立标题组件,但可通过以下方式实现:
<h2 class="el-title">二级标题</h2>
<style>
.el-title {
color: #303133;
margin: 16px 0;
font-weight: 500;
}
</style>
表格(Table)列标题
在 Table 组件中,通过 label 属性设置列标题:
<el-table :data="tableData">
<el-table-column prop="date" label="日期标题"></el-table-column>
</el-table>
注意事项
- 若需全局统一标题样式,建议在 SCSS 中定义变量:
$--font-size-extra-large: 20px; $--font-size-large: 18px; - 对话框标题支持 HTML 片段,需注意 XSS 防护
- 移动端适配时可通过媒体查询调整标题字号
以上方法覆盖了 Element UI 中常见标题场景的实现需求。







