news 2026/6/10 7:13:43

Eltable二次封装

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Eltable二次封装

封装

<template> <div> <el-table :data="tableData" border stripe :header-row-style="{ background: '#F1F6FF !important', color: '#3E445', fontWeight: '500', }" > <template v-for="(item, index) in column" > <el-table-column v-if="item.slot" :align="item.align" :label="item.label" :min-width="item.minWidth" :width="item.width" :fixed="item.fixed" > <template slot-scope="scope"> <slot :name="item.slot" :row="scope.row"></slot> </template> </el-table-column> <el-table-column v-else :align="item.align" :prop="item.prop" :label="item.label" :width="item.width" :min-width="item.minWidth" ></el-table-column> </template> </el-table> <el-pagination v-if="total" background layout="total, sizes, prev, pager, next" :page-sizes="pageSizes" :page-size="pageSize" :current-page="currentPage" :total="total" class="fyDiv" @size-change="handleSize" @current-change="handlePage" ></el-pagination> </div> </template> <script> export default { props: { tableData: { type: Array, default: () => [] }, column: { type: Array, default: () => [] }, total: { type: Number, default: () => 0 }, pageSizes: { type: Array, default: () => [10, 20, 30, 40], }, pageSize: { type: Number, default: () => 10 }, currentPage: { type: Number, default: () => 1 }, }, data() { return { } }, methods: { handleSize(){ this.$emit('handleSize') }, handlePage(){ this.$emit('handlePage') }, } } </script> <style lang="scss" scoped> ::v-deep .el-table__cell{ min-height: 46px; } </style>

使用

<TablePage :column="column" :tableData="customerTable" > <template #level="scope"> {{ scope.row.level | CustomerLevelType }} </template> <template #stage="scope"> {{ scope.row.stage | CustomerStageType }} </template> <template #type="scope"> {{ scope.row.type | CustomerStageType }} </template> <template #action="scope"> <el-link type="primary" :underline="false" @click="openCustomer('edit',scope.row)" style="">按钮</el-link> <el-link type="primary" :underline="false" @click="openDetails(scope.row.id)">按钮</el-link> </template> </TablePage>

数据格式

column: [ { label: '客户ID', prop: 'number', minWidth: 150, },{ label: '客户名称', slot: 'name', minWidth: 180, },{ label: '客户级别', prop: 'levelStr', minWidth: 100, },{ label: 'POI名称', slot: 'poiName', minWidth: 150, } ]
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/10 13:54:57

15、探索 Spotlight 与 I/O 重定向的强大功能

探索 Spotlight 与 I/O 重定向的强大功能 1. 认识元数据与 mdls 命令 在计算机的日常使用中,我们常常会接触到与文件相关的数据,例如文件名、文件大小和创建日期等。但实际上,很多文件还包含了额外的补充信息,这些信息被称为元数据。元数据在 Spotlight 中起着核心作用。…

作者头像 李华
网站建设 2026/6/10 6:26:11

Qt 入门实战(二):HelloWorld 的两种方式与控件内存管理

Qt 学起来挺有意思的&#xff0c;但初学者往往会被一些细节绕晕。 在上一篇博客里&#xff0c;我们讲了 Qt 的环境搭建和基础概念&#xff0c;这篇我们直接来动手做一个最简单的 HelloWorld&#xff0c;顺便把控件的生命周期、堆栈分配、QString 这些关键点顺便梳理一下。一、H…

作者头像 李华
网站建设 2026/6/10 1:47:54

一体化负氧离子传感器:支持24小时连续在线监测,可实时输出数据

一体化负氧离子传感器是一款功能强大且高度集成的环境监测设备&#xff0c;在众多领域发挥着至关重要的作用。从功能上看&#xff0c;它以精准测量负氧离子浓度为核心&#xff0c;同时还能同步监测多种环境参数。像温度、湿度、PM2.5、PM10、气压、氧含量、噪声、风速、风向等&…

作者头像 李华
网站建设 2026/6/10 13:54:35

护网入门平民化挖掘技巧分享(思路+例子)

【网络安全干货】护网行动实战经验分享&#xff1a;漏洞挖掘到内网渗透的完整流程&#xff0c;新手必藏 文章分享了护网行动中的漏洞挖掘和渗透测试经验&#xff0c;包括0day、Nday漏洞利用&#xff0c;白盒与黑盒审计方法&#xff0c;以及普通人可用的指纹识别和接口泄露等技…

作者头像 李华
网站建设 2026/6/10 13:52:09

AI时代产品经理的救命稻草:零基础入门AI产品,薪资暴涨40-60%!

简介 传统产品经理技能在AI时代迅速贬值&#xff0c;63%企业转型AI产品&#xff0c;AI产品人才稀缺且薪资上涨40-60%。文章推广"零基础入门AI产品经理"课程&#xff0c;内容包括AI产品应用原理、行业案例解析和求职辅导&#xff0c;适合产品经理、创业者、程序员等人…

作者头像 李华