vue 点击表头可任意排序的表格组件

这篇博客介绍了一个Vue组件,该组件允许用户通过点击表头进行数据排序。内容包括组件的引入、注册、方法实现,以及如何设置表格初始化参数和排序方法。表格数据和表头定义在`data`中,排序方法根据点击的表头字段更新排序状态并重新请求数据。
摘要由CSDN通过智能技术生成

1.组件内容(我放到了base/commonTable/index.vue下)

index.vue

<template>
    <el-table stripe :data="tableProps.tableData" :border="tableProps.border" class="c_el_table" :header-cell-style="getRowClass" @sort-change="sortchange">
        <el-table-column :label="item.keyName" :min-width="item.width" v-for="(item,index) in tableProps.dictionary" :key="index" sortable="custom" >
            <template slot-scope="scope">
                <div>
                    <span class="item" :style="{color:item.color,cursor: item.cursor,height:item.height}" v-html="scope.row[item.key]"></span>
                </div>
            </template>
        </el-table-column>

        <el-table-column style="border:1px solid red;" :label="tableProps.operateTitle" :min-width="tableProps.operateWidth" v-if="tableProps.operateTitle != undefined" >
            <template slot-scope="scope">
                <span  class="operate-table" 
                @click="handleDetails(scope.$index,subIndex ,scope.row)" 
                v-for="(subItem, subIndex) in tableProps.operate" 
                
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值