【vue3】el-table表头和表格文字都居中

时间:2025-03-18 07:59:40

1、表头文字居中 ::cell-style="{ textAlign: 'center' }"

<el-table :data="table" border style="width:550px;height:590px;"
            :default-sort="{ prop: 'f208', order: 'descending' }" stripe :header-cell-style="{ textAlign: 'center' }"
            :cell-style="{ textAlign: 'center' }">
            <el-table-column prop="f208" label="code" sortable> </el-table-column>
            <el-table-column prop="f207" label="名称" sortable> </el-table-column>
            <el-table-column prop="f14" label="类型" sortable> </el-table-column>
            <el-table-column fixed="right" label="操作">
              <template #default="scope">
                <el-button type="text" size="small">
                  查询
                </el-button>
              </template>
            </el-table-column>
</el-table>

 2、表格内文字居中::header-cell-style="{ textAlign: 'center' }"