更新记录

1.0.0(2026-03-10) 下载此版本

初次发布


平台兼容性

uni-app(3.6.18)

Vue2 Vue3 Vue3插件版本 Chrome Chrome插件版本 Safari app-vue app-vue插件版本 app-nvue Android Android插件版本 iOS iOS插件版本 鸿蒙
- 1.0.0 1.0.0 - 1.0.0 - 8.0 1.0.0 15 1.0.0 -
微信小程序 微信小程序插件版本 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
1.0.0 - - - - - - - - - - -

介绍

参考element-ui表格

表格属性

参数名称 类型 默认值 说明 是否必填
fieldList Array [] 表格列配置数组,定义每列的字段、标题、宽度等
dataList Array [] 静态数据列表,当 request 为空时直接使用该数据渲染表格
request Function null 异步请求函数,用于动态获取表格数据,需返回 Promise
requestResultConfig Object null 请求结果解析配置,默认接受字段为 { list: [], totalPage: 1, totalRow: 1 } 用于映射接口返回结构
paramsFun Function null 请求前的参数处理函数,接收分页参数,返回自定义请求参数对象 示例 paramsFun = ({ page, limit }) => ({ page, limit, ... })
spanMethod Function null 行列合并方法,参数 { row, column, rowIndex, columnIndex },返回 { rowspan, colspan }
rowHeight Number / String 100 表格行高
rowKey String 'id' 行数据的唯一标识字段名,用于性能优化和选中状态管理
minColumnWidth Number 150 列的最小宽度,防止内容挤压
tableLabel String 'name' fieldList显示文本字段名
tableValue String 'fieldName' fieldList数据项的值字段名
textAlign String 'center' 单元格内容对齐方式,可选值:'left' / 'center' / 'right'
type String 'select' 组件模式,'select':选择器模式;否则纯表格展示模式
isMultiple Boolean true 是否支持多选,仅在 type='select' 时生效
showPagination Boolean true 是否显示分页组件,适用于数据量较大场景
paginationInfo Function null 分页信息自定义格式化函数,接收 { current, total, totalCount },返回显示字符串

使用示例

<template>
    <cdj-table
    :fieldList="fieldList"
    :dataList="dataList"
    :paginationInfo="paginationInfo"
    :paramsFun="paramsFun"
    :request="request"
    :spanMethod="spanMethod"
    @selection-change="selectionChange" />
</template>

<script setup>
    import { fieldList, dataList } from './table'

    const paginationInfo = ({ current, total, totalCount }) => {
      return `共${ total }页 / 共${ totalCount }条`
    }

    const paramsFun = ({ page, limit }) => {
      return {
        page,
        limit
      }
    }

    const request = (params) => {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          const { page, limit } = params

          resolve({
            code: 200,
            msg: '操作成功',
            data: {
              list: dataList.slice((page - 1) * limit, page * limit),
              totalPage: Math.ceil(dataList.length / limit),
              totalRow: dataList.length
            }
          })
        }, 2000);
      })
    }

    const selectionChange = (data) => {
      console.log(data, '选中行');
    }

    const spanMethod = ({ row, column, rowIndex, columnIndex }) => {
      // return {
      //   rowspan: 1,
      //   colspan: 1
      // }

      // if (rowIndex % 2 === 0) {
      //   if (columnIndex === 0) {
      //     return {
      //       rowspan: 1,
      //       colspan: 2
      //     };
      //   } else if (columnIndex === 1) {
      //     return {
      //       rowspan: 0,
      //       colspan: 0
      //     }
      //   }
      // }

      if (columnIndex === 0) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    }
</script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。