1.0.12 • Published 2 years ago

vue-stability-table v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vue-stability-table

基于vue的表格组件,高性能,支持一次性显示10万条、1万列的数据

Demo

Simple usage

通过npm 或者 yarn安装

yarn add vue-stability-table

npm i vue-stability-table

引入

import 'vue-stability-table/dist/style.css'
import vueStabilityTable from 'vue-stability-table'
<template>
  <div style="height:432px;width:800px;">
    <stabilityTable ref="stabiltyTable" :columns="columns" :dataSource="rows"></stabilityTable>
  </div>
</template>

<script>
import 'vue-stability-table/dist/style.css'
import vueStabilityTable from 'vue-stability-table'

export default {
  components: { vueStabilityTable },
  data () {
    return {
      columns: [],
      rows: []
    }
  },
  created () {
    let columns = [{
      label: '固定列asadfasdfas',
      prop: 'table',
      fixed: true,
      width: 120,
      className: 'table-1',
      sortable: true,
      resizable: true
    }, {
      label: '固定列2',
      prop: 'fixedTable2',
      fixed: true,
      width: 120,
      resizable: true
    }]
    
    for (let i = 0; i <= 300; i++) {
      columns.push({
        label: '表头' + i,
        prop: 'table' + i,
        subProp: 'subTable' + i,
        resizable: true,
        sortable: true,
        formatter: function(str) {
          return str + 'bba'
        }
      })
    }

    columns.push({
      label: '固定尾1',
      prop: 'tableLast',
      fixed: true,
      width: 120,
      resizable: true,
      sortable: true,
      align: 'center'
    },{
      label: '固定尾2',
      prop: 'tableLast2',
      fixed: true,
      width: 120,
      resizable: true,
      sortable: true,
      align: 'right'
    })

    let rows = []
    for (let i = 0; i < 1000; i++) {
      let obj = {
        id: i,
        table: '是否' + i,
        fixedTable2: '收到',
        table1: i,
        table2: i,
        subTable1: '20%',
        children: []
      }
      for (let j = 0; j < 7; j++) {
        obj.children.push({
          id: i + 'ch' + j,
          fixedTable2: '2021111' + j,
          table1: '爱爱上爱上爱上爱上上',
          table2: 'asfasdasfasdfsffsfasfasdasfasdfsffsf'
        })
      }
      rows.push(obj)
    }
    this.columns = columns
    this.rows = rows
  }
}
</script>

Api

table props

name类型默认值说明
columnsArray[]表格列的配置描述
dataSourceArray[]数据数组
childrenColumnNameStringchildren指定树形结构的字段名
indentSizeNumber16树形结构缩进宽度
rowKeyStringid表格行key的字段名
rowSizeNumber40单行平均高度,虚拟滚动时用到
colSizeNumber100单列平均宽度,虚拟滚动时用到
openIconColumnNumber0展开图标显示列
scrollDisplayTypeStringshow滚动条展示类型
sortMarkBoolean1是否显示排序背景色

columns props

name类型默认值说明
labelString-列名
propString-表格内容对应的属性,支持多层访问:如
subPropString-表格内容对应的子属性
alignStringleft对齐方式
fixedBooleanfalse是否固定列
resizableBooleanfalse是否可拖动调整宽度,此时 width 必须是 number 类型
widthNumber100列宽度
minWidthNumber80列最小宽度
maxWidthNumber-列最大宽度
formatterFunction-本列格式化函数
sortableBooleanfalse是否排序
classNameString-本列样式类名

事件

name回调参数说明
on-expand-changefunction(row: Object, expandState: Boolean)拓展行展开收起
cell-text-clickfunction(columns: Object, row: Object, event: Element)点击单元格文本
resize-columnfunction(columns: Object)拖拽列宽改变后
on-sort-changefunction(colProp: String, sortOrders: String, columns: Object)自定义排序,监听该事件后,系统默认排序会失效
scrollfunction(scrollValue: Object, $event)滚动会触发该事件
scroll-hitfunction(type: String, scrollValue: Object)滚动条触底、触顶、触左、触右后出发该事件

方法

name参数说明
updateColumns(columns)-手动更新列数据(比直接改变props的columns性能高25%左右)
updateRows(rows)-手动更新行数据(比直接改变props的dataSource性能高25%左右)
doLayout()-表格重新布局

solt

name说明
content行单元格内容 参数: {row, column, content, rowIndex}
header表头内容 参数: { column }
expand自定义扩展行内容 参数:{ row }
1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago