前言:哈喽,大家好,今天给大家分享一篇文章!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕

目录
- [DeepSeek 助力 Vue3 开发:打造丝滑的表格(Table)之添加列宽调整功能,示例Table14_02带边框和斑马纹的固定表头表格](#DeepSeek 助力 Vue3 开发:打造丝滑的表格(Table)之添加列宽调整功能,示例Table14_02带边框和斑马纹的固定表头表格)
📚📗📕📘📖🕮💡📝🗂️✍️🛠️💻🚀🎉🏗️🌐🖼️🔗📊👉🔖⚠️🌟🔐⬇️·正文开始
⬇️·🎥😊🎓📩😺🌈🤝🤖📜📋🔍✅🧰❓📄📢📈 🙋0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟🆗*️⃣#️⃣
DeepSeek 助力 Vue3 开发:打造丝滑的表格(Table)之添加列宽调整功能,示例Table14_02带边框和斑马纹的固定表头表格
📚页面效果

📘组件代码
html
<!-- 带边框和斑马纹的固定表头表格 -->
<template>
<div class="table-demo">
<h2>2. 添加表头固定功能,带边框和斑马纹的固定表头表格</h2>
<p class="description">使用 border 和 stripe 属性美化固定表头表格</p>
<div class="table-container">
<Table
:data="customers"
:columns="columns"
fixed-header
fixed-header-height="300px"
stripe
border
/>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
import Table from '@/components/Table/Table.vue'
const customers = ref([
{ id: 1, name: '张三', age: 28, city: '北京', level: '黄金' },
{ id: 2, name: '李四', age: 35, city: '上海', level: '白银' },
{ id: 3, name: '王五', age: 42, city: '广州', level: '铂金' },
{ id: 4, name: '赵六', age: 31, city: '深圳', level: '黄金' },
{ id: 5, name: '钱七', age: 29, city: '杭州', level: '白银' },
{ id: 6, name: '孙八', age: 45, city: '成都', level: '钻石' },
{ id: 7, name: '周九', age: 33, city: '武汉', level: '黄金' },
{ id: 8, name: '吴十', age: 38, city: '南京', level: '铂金' }
])
const columns = ref([
{ title: '姓名', dataIndex: 'name', width: '120px' },
{ title: '年龄', dataIndex: 'age', width: '80px' },
{ title: '城市', dataIndex: 'city', width: '120px' },
{ title: '会员等级', dataIndex: 'level', width: '120px' }
])
</script>
<style scoped>
.table-demo {
padding: 20px;
}
.description {
margin: 16px 0;
color: #333;
font-weight: 500;
}
.table-container {
border: 1px solid #ebeef5;
border-radius: 4px;
position: relative;
height: 400px;
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15);
overflow: hidden;
}
:deep(.table-container) {
height: 300px;
}
:deep(.body-container) {
padding-top: 41px;
width: calc(100% + 17px); /* 补偿滚动条宽度 */
}
:deep(.fixed-header-container) {
background: white;
z-index: 10;
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
}
/* 表格布局固定 */
:deep(.header-table),
:deep(.body-table) {
table-layout: fixed;
width: 100%;
}
/* 确保列宽一致 */
:deep(.header-table colgroup),
:deep(.body-table colgroup) {
display: table-column-group;
}
/* 调整滚动条样式 */
:deep(.body-container::-webkit-scrollbar) {
width: 17px;
}
:deep(.body-container::-webkit-scrollbar-track) {
background: #f1f1f1;
}
:deep(.body-container::-webkit-scrollbar-thumb) {
background: #c1c1c1;
border: 4px solid #f1f1f1;
border-radius: 10px;
}
/* 表头样式增强 */
:deep(th) {
background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%) !important;
color: #606266;
font-weight: bold;
font-size: 14px;
border-bottom: 1px solid #dcdfe6;
text-transform: uppercase;
letter-spacing: 0.5px;
}
/* 斑马纹样式增强 */
:deep(.stripe-row) {
background-color: #f0f7ff;
}
/* 边框样式增强 */
:deep(th), :deep(td) {
border-right: 1px solid #ebeef5;
padding: 12px 16px;
transition: all 0.3s ease;
}
:deep(th:last-child), :deep(td:last-child) {
border-right: none;
}
/* 悬停效果 */
:deep(tr:hover:not(.stripe-row)) {
background-color: #ecf5ff;
transform: translateZ(0);
}
:deep(tr.stripe-row:hover) {
background-color: #e6f0fc;
transform: translateZ(0);
}
/* 单元格样式 */
:deep(td) {
color: #606266;
font-size: 14px;
line-height: 1.5;
}
/* 表格整体样式 */
:deep(.ds-table) {
background-color: #ffffff;
border: 2px solid #dcdfe6;
border-radius: 4px;
overflow: hidden;
}
/* 会员等级样式 */
:deep(td:last-child) {
font-weight: 600;
}
:deep(td:last-child:contains('黄金')) {
color: #f0b90b;
}
:deep(td:last-child:contains('白银')) {
color: #8c8c8c;
}
:deep(td:last-child:contains('铂金')) {
color: #40a9ff;
}
:deep(td:last-child:contains('钻石')) {
color: #722ed1;
}
</style>
📚测试代码正常跑通,附其他基本代码
- 添加路由
- 页面展示入口
📘编写路由 src\router\index.js

javascript
import { createRouter, createWebHistory } from 'vue-router'
import RightClickMenuView from '../views/RightClickMenuView.vue'
import RangePickerView from '../views/RangePickerView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'progress',
component: () => import('../views/ProgressView.vue'),
},
{
path: '/tabs',
name: 'tabs',
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
// 标签页(Tabs)
component: () => import('../views/TabsView.vue'),
},
{
path: '/accordion',
name: 'accordion',
// 折叠面板(Accordion)
component: () => import('../views/AccordionView.vue'),
},
{
path: '/timeline',
name: 'timeline',
// 时间线(Timeline)
component: () => import('../views/TimelineView.vue'),
},
{
path: '/backToTop',
name: 'backToTop',
component: () => import('../views/BackToTopView.vue')
},
{
path: '/notification',
name: 'notification',
component: () => import('../views/NotificationView.vue')
},
{
path: '/card',
name: 'card',
component: () => import('../views/CardView.vue')
},
{
path: '/infiniteScroll',
name: 'infiniteScroll',
component: () => import('../views/InfiniteScrollView.vue')
},
{
path: '/switch',
name: 'switch',
component: () => import('../views/SwitchView.vue')
},
{
path: '/sidebar',
name: 'sidebar',
component: () => import('../views/SidebarView.vue')
},
{
path: '/breadcrumbs',
name: 'breadcrumbs',
component: () => import('../views/BreadcrumbsView.vue')
},
{
path: '/masonryLayout',
name: 'masonryLayout',
component: () => import('../views/MasonryLayoutView.vue')
},
{
path: '/rating',
name: 'rating',
component: () => import('../views/RatingView.vue')
},
{
path: '/datePicker',
name: 'datePicker',
component: () => import('../views/DatePickerView.vue')
},
{
path: '/colorPicker',
name: 'colorPicker',
component: () => import('../views/ColorPickerView.vue')
},
{
path: '/rightClickMenu',
name: 'rightClickMenu',
component: RightClickMenuView
},
{
path: '/rangePicker',
name: 'rangePicker',
component: () => import('../views/RangePickerView.vue')
},
{
path: '/navbar',
name: 'navbar',
component: () => import('../views/NavbarView.vue')
},
{
path: '/formValidation',
name: 'formValidation',
component: () => import('../views/FormValidationView.vue')
},
{
path: '/copyToClipboard',
name: 'copyToClipboard',
component: () => import('../views/CopyToClipboardView.vue')
},
{
path: '/clickAnimations',
name: 'clickAnimations',
component: () => import('../views/ClickAnimationsView.vue')
},
{
path: '/thumbnailList',
name: 'thumbnailList',
component: () => import('../views/ThumbnailListView.vue')
},
{
path: '/keyboardShortcuts',
name: 'keyboardShortcuts',
component: () => import('../views/KeyboardShortcutsView.vue')
},
{
path: '/commentSystem',
name: 'commentSystem',
component: () => import('../views/CommentSystemView.vue')
},
{
path: '/qRCode',
name: 'qRCode',
component: () => import('../views/QRCodeView.vue')
},
{
path: '/radioButton',
name: 'radioButton',
component: () => import('../views/RadioButtonView.vue')
},
{
path: '/slider',
name: 'slider',
component: () => import('../views/SliderView.vue')
},
{
path: '/scrollAnimations',
name: 'scrollAnimations',
component: () => import('../views/ScrollAnimationsView.vue')
},
{
path: '/textInputView',
name: 'textInputView',
component: () => import('../views/TextInputView.vue')
},
{
path: '/divider',
name: 'divider',
component: () => import('../views/DividerView.vue')
},
{
path: '/checkbox',
name: 'checkbox',
component: () => import('../views/CheckboxView.vue')
},
{
path: '/tagInput',
name: 'tagInput',
component: () => import('../views/TagInputView.vue')
},
{
path: '/dropdownSelect',
name: 'dropdownSelect',
component: () => import('../views/DropdownSelectView.vue')
},
{
path: '/list',
name: 'list',
component: () => import('../views/ListView.vue')
},
{
path: '/header',
name: 'header',
component: () => import('../views/HeaderView.vue')
},
{
path: '/footer',
name: 'footer',
component: () => import('../views/FooterView.vue')
},
{
path: '/pagination',
name: 'pagination',
component: () => import('../views/PaginationView.vue')
},
{
path: '/floatingActionButton',
name: 'floatingActionButton',
component: () => import('../views/FloatingActionButtonView.vue')
},
{
path: '/gridLayout',
name: 'gridLayout',
component: () => import('../views/GridLayoutView.vue')
},
{
path: '/passwordInput',
name: 'passwordInput',
component: () => import('../views/PasswordInputView.vue')
},
{
path: '/flexbox',
name: 'flexbox',
component: () => import('../views/FlexboxView.vue')
},
{
path: '/modal',
name: 'modal',
component: () => import('../views/ModalView.vue')
},
{
path: '/richTextEditor',
name: 'richTextEditor',
component: () => import('../views/RichTextEditorView.vue')
},
{
path: '/timePickerView',
name: 'timePickerView',
component: () => import('../views/TimePickerView.vue')
},
{
path: '/multistepForm',
name: 'multistepForm',
component: () => import('../views/MultistepFormView.vue')
},
{
path: '/table1',
name: 'table1',
component: () => import('../views/TableView1.vue')
},
{
path: '/table2',
name: 'table2',
component: () => import('../views/TableView2.vue')
},
{
path: '/table3',
name: 'table3',
component: () => import('../views/TableView3.vue')
},
{
path: '/table4',
name: 'table4',
component: () => import('../views/TableView4.vue')
},
{
path: '/table5',
name: 'table5',
component: () => import('../views/TableView5.vue')
},
{
path: '/table6',
name: 'table6',
component: () => import('../views/TableView6.vue')
},
{
path: '/table7',
name: 'table7',
component: () => import('../views/TableView7.vue')
},
{
path: '/table8',
name: 'table8',
component: () => import('../views/TableView8.vue')
},
{
path: '/table9',
name: 'table9',
component: () => import('../views/TableView9.vue')
},
{
path: '/table10',
name: 'table10',
component: () => import('../views/TableView10.vue')
},
{
path: '/table11',
name: 'table11',
component: () => import('../views/TableView11.vue')
},
{
path: '/table12',
name: 'table12',
component: () => import('../views/TableView12.vue')
},
{
path: '/table12_02',
name: 'table12_02',
component: () => import('../views/TableView12_02.vue')
},
{
path: '/table14',
name: 'table14',
component: () => import('../views/TableView14.vue')
},
{
path: '/table14_01',
name: 'table14_01',
component: () => import('../views/TableView14_01.vue')
},
{
path: '/table14_02',
name: 'table14_02',
component: () => import('../views/TableView14_02.vue')
}
],
})
export default router
📘编写展示入口 src\App.vue

html
<script setup>
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
</script>
<template>
<header>
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
<div class="wrapper">
<HelloWorld msg="You did it!" />
<nav>
<RouterLink to="/">Progress</RouterLink>
<RouterLink to="/tabs">Tabs</RouterLink>
<RouterLink to="/accordion">Accordion</RouterLink>
<RouterLink to="/timeline">Timeline</RouterLink>
<RouterLink to="/backToTop">BackToTop</RouterLink>
<RouterLink to="/notification">Notification</RouterLink>
<RouterLink to="/card">Card</RouterLink>
<RouterLink to="/infiniteScroll">InfiniteScroll</RouterLink>
<RouterLink to="/switch">Switch</RouterLink>
<RouterLink to="/sidebar">Sidebar</RouterLink>
<RouterLink to="/breadcrumbs">Breadcrumbs</RouterLink>
<RouterLink to="/masonryLayout">MasonryLayout</RouterLink>
<RouterLink to="/rating">Rating</RouterLink>
<RouterLink to="/datePicker">DatePicker</RouterLink>
<RouterLink to="/colorPicker">ColorPicker</RouterLink>
<RouterLink to="/rightClickMenu">RightClickMenu</RouterLink>
<RouterLink to="/rangePicker">RangePicker</RouterLink>
<RouterLink to="/navbar">Navbar</RouterLink>
<RouterLink to="/formValidation">FormValidation</RouterLink>
<RouterLink to="/copyToClipboard">CopyToClipboard</RouterLink>
<RouterLink to="/clickAnimations">ClickAnimations</RouterLink>
<RouterLink to="/thumbnailList">ThumbnailList</RouterLink>
<RouterLink to="/keyboardShortcuts">KeyboardShortcuts</RouterLink>
<RouterLink to="/commentSystem">CommentSystem</RouterLink>
<RouterLink to="/qRCode">QRCode</RouterLink>
<RouterLink to="/radioButton">RadioButton</RouterLink>
<RouterLink to="/slider">Slider</RouterLink>
<RouterLink to="/scrollAnimations">ScrollAnimations</RouterLink>
<RouterLink to="/textInputView">TextInput</RouterLink>
<RouterLink to="/divider">Divider</RouterLink>
<RouterLink to="/checkbox">Checkbox</RouterLink>
<RouterLink to="/tagInput">TagInput</RouterLink>
<RouterLink to="/dropdownSelect">DropdownSelect</RouterLink>
<RouterLink to="/list">List</RouterLink>
<RouterLink to="/header">Header</RouterLink>
<RouterLink to="/footer">Footer</RouterLink>
<RouterLink to="/pagination">Pagination</RouterLink>
<RouterLink to="/floatingActionButton">FloatingActionButton</RouterLink>
<RouterLink to="/gridLayout">GridLayout</RouterLink>
<RouterLink to="/passwordInput">PasswordInput</RouterLink>
<RouterLink to="/flexbox">Flexbox</RouterLink>
<RouterLink to="/modal">Modal</RouterLink>
<RouterLink to="/richTextEditor">RichTextEditor</RouterLink>
<RouterLink to="/timePickerView">TimePickerView</RouterLink>
<RouterLink to="/multistepForm">MultistepFormView</RouterLink>
<RouterLink to="/table1">Table1</RouterLink>
<RouterLink to="/table2">Table2</RouterLink>
<RouterLink to="/table3">Table3</RouterLink>
<RouterLink to="/table4">Table4</RouterLink>
<RouterLink to="/table5">Table5</RouterLink>
<RouterLink to="/table6">Table6空状态</RouterLink>
<RouterLink to="/table7">Table7空状态2</RouterLink>
<RouterLink to="/table8">Table8基础加载状态</RouterLink>
<RouterLink to="/table9">Table9自定义加载文本</RouterLink>
<RouterLink to="/table10">Table10完全自定义加载内容</RouterLink>
<RouterLink to="/table11">Table11加载结合分页</RouterLink>
<RouterLink to="/table12">Table12启用列宽调整</RouterLink>
<RouterLink to="/table12_02">table12_02自定义选择列宽度</RouterLink>
<RouterLink to="/table14">table14 添加表头固定功能 </RouterLink>
<RouterLink to="/table14_01">table14_01</RouterLink>
<RouterLink to="/table14_02">table14_02</RouterLink>
</nav>
</div>
</header>
<RouterView />
</template>
<style scoped>
header {
line-height: 1.5;
max-height: 100vh;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
nav {
width: 100%;
font-size: 12px;
text-align: center;
margin-top: 2rem;
}
nav a.router-link-exact-active {
color: var(--color-text);
}
nav a.router-link-exact-active:hover {
background-color: transparent;
}
nav a {
display: inline-block;
padding: 0 1rem;
border-left: 1px solid var(--color-border);
}
nav a:first-of-type {
border: 0;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
nav {
text-align: left;
margin-left: -1rem;
font-size: 1rem;
padding: 1rem 0;
margin-top: 1rem;
}
}
</style>
📚页面效果

📚展望
在模型能力方面,GPT - 4 在自然语言处理任务上表现出色,能够理解和生成高质量的文本,在语言翻译、文本摘要、问答系统等多个领域都有广泛的应用。在处理多语言任务时,GPT - 4 能够准确地进行语言转换,保持原文的语义和风格。而 DeepSeek 在推理任务上表现卓越,特别是在数学、代码和自然语言推理等任务中,DeepSeek - R1 的性能与 GPT - 4 相当甚至更优。在 AIME 2024 数学竞赛基准测试中,DeepSeek - R1 的 pass@1 分数达到 79.8%,略高于 OpenAI - o1 - 1217,展现出了强大的数学推理能力。在代码生成任务中,DeepSeek 能够根据自然语言描述快速生成准确、高效的代码,其代码生成能力甚至超越了 GPT - 4 Turbo,为开发者提供了更强大的工具。
📚相关文章
------------ 相 关 文 章 ------------
-
DeepSeek 助力 Vue 开发:打造丝滑的导航栏(Navbar)https://blog.csdn.net/qq_33650655/article/details/145732421
-
DeepSeek 助力 Vue 开发:打造丝滑的二维码生成(QR Code)https://blog.csdn.net/qq_33650655/article/details/145797928
-
DeepSeek 助力 Vue 开发:打造丝滑的滑块(Slider)https://blog.csdn.net/qq_33650655/article/details/145817161
-
DeepSeek 助力 Vue 开发:打造丝滑的文本输入框(Text Input)https://blog.csdn.net/qq_33650655/article/details/145837003
-
DeepSeek 助力 Vue 开发:打造丝滑的分割线(Divider)https://blog.csdn.net/qq_33650655/article/details/145849100
-
DeepSeek 助力 Vue 开发:打造丝滑的 复选框(Checkbox)https://blog.csdn.net/qq_33650655/article/details/145855695
-
DeepSeek 助力 Vue3 开发:打造丝滑的标签输入(Tag Input)https://blog.csdn.net/qq_33650655/article/details/145858574
-
DeepSeek 助力 Vue3 开发:打造丝滑的列表(List)https://blog.csdn.net/qq_33650655/article/details/145866384
-
DeepSeek 助力 Vue3 开发:打造丝滑的页眉(Header)https://blog.csdn.net/qq_33650655/article/details/145885122
-
DeepSeek 助力 Vue3 开发:打造丝滑的页脚(Footer)https://blog.csdn.net/qq_33650655/article/details/145886306
-
DeepSeek 助力 Vue3 开发:打造丝滑的分页(Pagination)https://blog.csdn.net/qq_33650655/article/details/145886824
-
DeepSeek 助力 Vue3 开发:打造丝滑的弹性布局(Flexbox)https://blog.csdn.net/qq_33650655/article/details/145938677
-
DeepSeek 助力 Vue3 开发:打造丝滑的模态框(Modal)https://blog.csdn.net/qq_33650655/article/details/145938939
到此这篇文章就介绍到这了,更多精彩内容请关注本人以前的文章或继续浏览下面的文章,创作不易,如果能帮助到大家,希望大家多多支持宝码香车~💕,若转载本文,一定注明本文链接。

更多专栏订阅推荐:
💕 vue
✈️ Electron
⭐️ js
📝 字符串