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;

效果:

相关推荐
SuperEugene2 小时前
Vue3 模板语法规范实战:v-if/v-for 不混用 + 表达式精简,避坑指南|Vue 组件与模板规范篇
开发语言·前端·javascript·vue.js·前端框架
Luna-player2 小时前
Vue 3 + Vue Router 的路由配置,简单示例
前端·javascript·vue.js
xiaotao1312 小时前
03. 原子化 CSS 思想
前端·css·tailwind
angerdream2 小时前
最新版vue3+TypeScript开发入门到实战教程之Vue3详解props
javascript·vue.js
爱宇阳3 小时前
Nuxt4 + Tailwind CSS v4 自定义响应式断点完整指南
前端·css·nuxt4
~欲买桂花同载酒~3 小时前
项目优化-vite打包优化
前端·javascript·vue.js
踩着两条虫4 小时前
AI 驱动的 Vue3 应用开发平台 深入探究(二十):CLI与工具链之构建配置与Vite集成
前端·vue.js·ai编程
踩着两条虫4 小时前
AI 驱动的 Vue3 应用开发平台 深入探究(二十):CLI与工具链之自定义构建插件
前端·vue.js·ai编程
极梦网络无忧6 小时前
基于 Vite + Vue3 的组件自动注册功能
前端·javascript·vue.js
雪碧聊技术7 小时前
前端vue代码架子搭建
前端·javascript·vue.js·前端项目代码框架搭建