vue中table内容和lable对不齐解决方案

问题:

代码片段:

bash 复制代码
<template>
    <el-table :data="tableData" stripe style="width: 100%">

        <el-table-column prop="title" label="标题" width="80px" />
        <el-table-column prop="name" label="内容" width="80px" />
        <el-table-column prop="address" label="发布人" width="80px" />
        <el-table-column prop="date" label="发布时间" width="100px" />

        <el-table-column label="操作" width="200px">
            <template #default="scope">
                <el-button type="primary" size="small" @click="handleEdit(scope.row)">编辑</el-button>
                <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

解决问题:

1.添加 <el-table-column/>

bash 复制代码
<template>
    <el-table :data="tableData" stripe style="width: 100%">
        <el-table-column />
        <el-table-column prop="title" label="标题" width="80px" />
        <el-table-column prop="name" label="内容" width="80px" />
        <el-table-column prop="address" label="发布人" width="80px" />
        <el-table-column prop="date" label="发布时间" width="100px" />

        <el-table-column label="操作" width="200px">
            <template #default="scope">
                <el-button type="primary" size="small" @click="handleEdit(scope.row)">编辑</el-button>
                <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

效果:

2.给table添加:display: table-cell;

效果:

相关推荐
前天的五花肉14 分钟前
D3.js研发Biplot(代谢)图
前端·javascript·css
武昌库里写JAVA26 分钟前
java设计模式 - 工厂方法模式
vue.js·spring boot·sql·layui·课程设计
i_am_a_div_日积月累_39 分钟前
el-tree半选回显问题;el-tree获取半选节点id
javascript·vue.js·elementui
lcc18739 分钟前
CSS 浮动
css
kirinlau42 分钟前
Vue.observable实现vue原生轻量级状态管理详解
前端·javascript·vue.js
编代码的小王1 小时前
【无标题】
前端·css
仰望.1 小时前
vxe-table 按多个列进行分组和按多个字段进行分组的使用方式
vue.js·vxe-table
be or not to be1 小时前
HTML 与 CSS 基础入门笔记
css·笔记·html
BD_Marathon1 小时前
Vue3_双向绑定
前端·javascript·vue.js
仰望.1 小时前
vue 甘特图 vxe-gantt 手动增加一条依赖线,删除连接线的用法
vue.js·甘特图·vxe-ui·vxe-gantt