当前位置: 首页 > news >正文

uniapp-vue3-table:基于uni-app+vue3跨端自定义表格table组件

最新研发uniapp+vue3跨端自定义表格table组件|uni-app增强版table

uni-vue3-table:基于uniapp+vue3全端通用自定义加强版table组件。支持固定表头/列、边框、斑马纹、单选/多选,自定义表头/表体内容插槽、左右固定列阴影高亮。支持编译运行web+小程序端+app端

编译运行到H5+小程序+App端。

未标题-2

uni-vue3-table表格组件修复当列数过多,左右滚动会导致固定在左侧/右侧列也会随着一起滚动问题

p2-1

p1

uniapp+vue3自定义表格

image

将uv3-table组件放在components目录,在页面template中即可直接使用。

  • Props参数

image

  • columns列参数
/*** 列参数* @params {string} background 对应列背景色* @params {string} type 对应列类型(多选selection 索引index)* @params {string} label 显示的列标题* @params {string} prop 对应的列字段名* @params {string} align 列水平对齐方式(left center right)* @params {number|string} width 对应列宽度* @params {boolean|string} fixed 该列固定到左侧(fixed:true|'left')或右侧(fixed:'right')* @params {string} columnStyle 对应列自定义样式* @params {string} className/class 表格列的类名className*/
  • 事件
@headerClick 点击表头
@rowClick    点击行触发
@select    多选/单选
  • 自定义插槽
headerCell 自定义表头内容
default 默认表体内容
empty 无数据插槽

未标题-1

uni-vue3-table使用示例

  • 模拟数据
<script setup>import { ref } from 'vue'import Mock from 'mockjs'// 表格数据const data = ref(Mock.mock({total: 100,page: 1,pagesize: 10,'list|20': [{id: '@id()',author: '@cname()',title: '@ctitle(10, 50)',image: 'https://picsum.photos/400/400?random=' + '@guid()',switch: '@boolean()','tags|1': ['admin', 'test', 'dev'],rate: '@integer(1, 5)',date: '@datetime()',color: '@color()',}]}))// 表格列const columns = ref([{type: 'selection', align: 'center', width: 80, fixed: true}, // 多选{type: 'index', label: 'ID', align: 'center', width: 80, fixed: true}, // 索引序号{prop: 'author', label: '作者', align: 'center', width: 120},{prop: 'title', label: '标题', align: 'left', width: '350px'},{prop: 'image', label: '图片', align: 'center', width: '120px'},{prop: 'switch', label: '推荐', align: 'center', width: 100},{prop: 'tags', label: '标签', align: 'center', width: 100},{prop: 'rate', label: '评分', align: 'center', width: 200},{prop: 'date', label: '发布时间', align: 'left', width: '250px'}, // 时间{prop: 'date', label: '更新时间', align: 'left', width: '250px'}, // 时间{prop: 'action', label: '操作', align: 'center', width: 150, fixed: 'right'}, // 操作
  ])
</script>
  • 基本用法
<uv3-table :columns="columns" :dataSource="data.list" />
  • 自定义表格条纹/颜色、高度
<uv3-table:columns="columns":dataSource="data.list"stripestripeColor="#eee"padding="5px"height="300px"
/>
  • 综合用法(固定左侧/右侧列、自定义表头/表体插槽、表格事件)
<uv3-table:dataSource="data.list":columns="columns":headerBold="true"headerBackground="#ecf5ff"stripeborderpadding="5px"maxHeight="500px"@rowClick="handleRowClick"@select="handleSelect"
><!-- 自定义header插槽内容 --><template #headerCell="{ key, col, index }"><template v-if="key == 'title'"><view class="flex-c">{{col.label}} <input placeholder="搜索" /></view></template><template v-else-if="key == 'date'"><uni-icons type="calendar"></uni-icons> {{col.label}}</template><template v-else>{{col.label}}</template></template><!-- 自定义body插槽内容(由于小程序不支持动态:name插槽,通过key标识l来自定义表格内容) --><template #default="{ key, value, row, col, index }"><template v-if="key == 'image'"><uv-image :src="value" lazyLoad observeLazyLoad width="80rpx" height="80rpx" @click="previewImage(value)" /></template><template v-else-if="key == 'switch'"><switch :checked="value" style="transform:scale(0.6);" /></template><template v-else-if="key == 'tags'"><uv-tags :text="value" :color="row.color" :borderColor="row.color" plain size="mini" /></template><template v-else-if="key == 'rate'"><uni-rate :value="value" size="14" readonly /></template><template v-else-if="key == 'action'"><uni-icons type="compose" color="#00aa7f" @click="handleEdit(row)" /><uni-icons type="trash" color="#ff007f" style="margin-left: 5px;" @click="handleDel(row)" /></template><template v-else>{{value}}</template></template>
</uv3-table>

360截图20250817064911265

003360截图20250816223247082

004360截图20250816223412275

006360截图20250816223905645

M003360截图20250816231328348

App004360截图20250817000932130

uni-vue3-table表格组件已经更新到我的原创作品集。

uniapp+vue3跨端自定义table表格组件

综上就uniapp+vue3自定义表格组件的一些知识分享,感谢大家的阅读与支持。

附上几个最新项目实例

最新版uni-app+vue3+uv-ui跨三端仿微信app聊天应用【h5+小程序+app端】

Flutter3-MacOS桌面OS系统|flutter3.32+window_manager客户端OS模板

最新研发flutter3.27+bitsdojo_window+getx客户端仿微信聊天Exe应用

最新版uniapp+vue3+uv-ui跨三端短视频+直播+聊天【H5+小程序+App端】

Uniapp-DeepSeek跨三端AI助手|uniapp+vue3+deepseek-v3流式ai聊天模板

Electron35-DeepSeek桌面端AI系统|vue3.5+electron+arco客户端ai模板

vue3-webseek网页版AI问答|Vite6+DeepSeek+Arco流式ai聊天打字效果

flutter3-dymall仿抖音直播商城|Flutter3.27短视频+直播+聊天App实例

Tauri2.0+Vite5聊天室|vue3+tauri2+element-plus仿微信|tauri聊天应用

Electron32-ViteOS桌面版os系统|vue3+electron+arco客户端OS管理模板

Electron31-Vue3Admin管理系统|vite5+electron+pinia桌面端后台Exe

 

http://www.sczhlp.com/news/13660/

相关文章:

  • [笔记]CDQ分治
  • 12 橙青风格,教你修出INS的最新潮流
  • 15 仿色技巧,让你自由模仿各种流行调色
  • 14 举一反三,让你修图不再发愁没思路
  • 16 结语:修图最有意义的部分是技巧以外的个性
  • 7 局部调整,精细刻画画面细节
  • 6 色彩调整,快速打造任意色调
  • 10 蓝金风格,教你修出高级感城市夜景
  • 9 曝光及全景合成,轻松超越相机和镜头极限
  • 11 胶片风格,教你修出生活的散文诗
  • 牛市顶点需要关注的一些指标
  • 1 先导课:称霸朋友圈的大片是怎么调出来的
  • 02011701 转换
  • 摄影创作实战课:人像风光旅行静物生活纪实
  • 18 实战案例:人像写真拍摄指南
  • 20 实战案例:星空如何拍
  • 19 实战案例:月亮如何拍
  • 13 摄影用光指南:如何利用好光线
  • 15 如何对优秀摄影作品进行拆解和学习
  • 17 实战案例:城市风光拍摄指南
  • 16 实战案例:自然风光拍摄指南
  • 09 一节课弄懂对焦、景深和虚化那些事
  • 10 摄影构图核心的奥秘
  • 11 数码时代的正确曝光与影调
  • [POI 2007] OSI-Axes of Symmetry
  • 12 大光比场景下,平衡光比的多种应对方式
  • [飞行器/低空经济] 中国低空经济的政府监管体系
  • 06 学会这课,焦距、透视、畸变三个概念不会再分不清
  • 二次函数的图像与性质
  • 07 一节课教会你掌握正确的曝光参数