有时el-table的默认样式不能满足我们的要求,需要我们修改它的样式来达到我们的需求

1、 默认的el-table表格

<template>
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" width="250" />
  </el-table>
</template>
<script setup>
const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  }
]
</script>
<style lang="less" scoped></style>

在这里插入图片描述

2、表格内容样式

  <el-table
    :data="tableData"
    border // 显示竖线边框
    style="width: 100%; height: 100%; font-size: 15px; color: red; border-radius: 10px" // 设置表格整体样式 
    :header-cell-style="{ 'font-size': '20px', color: '#41b883' }" // 设置表头样式
    :row-style="{ height: '60px' }" // 设置tbody的行高
    :cell-style="{ padding: '30px 0' }" // 设置tbody的行间距
  >

在这里插入图片描述

3、去掉竖线边框

<el-table
    :data="tableData"
  	// 删除border
    style="width: 100%; height: 100%; font-size: 15px; color: red; border-radius: 10px"
    :header-cell-style="{ 'font-size': '20px', color: '#41b883' }"
    :row-style="{ height: '60px' }"
    :cell-style="{ padding: '30px 0' }"
  >

在这里插入图片描述

4、去掉所有边框

 <el-table
    :data="tableData"
    border
    style="width: 100%; 
      height: 100%; 
      font-size: 15px; 
      color: red; 
      --el-table-border-color: none" // 去掉表格所有边框
    :header-cell-style="{ 'font-size': '20px', color: '#41b883' }"
    :row-style="{ height: '60px' }"
    :cell-style="{ padding: '30px 0' }"
  >

在这里插入图片描述

5、对边框某一边单独操作

这部分,可以F12打开开发者工具,去进行调试,找到该样式,去强制修改成自己的样式即可
在这里插入图片描述

GitHub 加速计划 / eleme / element
13
1
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:18 天前 )
c345bb45 1 年前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 1 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐