1.1.1 • Published 4 years ago

tree-table-vue-fixed v1.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

tree-table-vue

A table(with tree-grid) component development based on vue-table-with-tree-grid @MisterTaki)

在vue-table-with-tree-grid v0.2.4版本基础上,修复了vue新版本对重复key检测造成的警告

添加了自定义显示展开子级按钮的属性expand-key

注意:v1.0.7版本开始,修改了columns的prop属性为key,label属性为title,修改selection-type为selectable,添加了select-type属性

作者系列视频课程:

Vue技术栈开发实战(26课时)

TypeScript完全解读(26课时)

Example

Example

Installation

Use npm:

npm i tree-table-vue -S

Or use yarn:

yarn add tree-table-vue

Usage

import Vue from 'vue'
import TreeTable from 'tree-table-vue'

Vue.use(TreeTable)

Or

import Vue from 'vue'
import TreeTable from 'tree-table-vue'

Vue.component(TreeTable.name, TreeTable)

more information please see example..., or git clone this repository and open dev mode (I will give it a homepage later...).

API

Table Attributes

属性说明类型参数默认值
data表格各行的数据Array-[]
empty-text表格数据为空时显示的文字String-'暂无数据'
columns表格各列的配置(具体见下文:Columns Configs)Array-[]
expand-key需要显示展开按钮的列的key(columns列对象里的prop)String-默认是第一列的prop
show-header是否显示表头Boolean-true
show-index是否显示数据索引Boolean-false
index-text数据索引名称String-'序号'
show-summary是否显示表尾合计行Boolean-false
sum-text表尾合计行首列名称String-'合计'
summary-method表尾合计行计算方法Functiondata, column, columnIndex-
max-height最大高度String, Number-'auto'
stripe是否显示间隔斑马纹Boolean-false
border是否显示纵向边框Boolean-false
show-row-hover鼠标悬停时,是否高亮当前行Boolean-true
tree-type是否为树形表格Boolean-false
children-prop树形表格中遍历的属性名称String-'children'
is-fold树形表格中父级是否默认折叠Boolean-true
expand-type是否为展开行类型表格(为 True 时,需要添加名称为 '$expand' 的作用域插槽, 它可以获取到 row, rowIndex)Boolean-false
selectable是否为多选类型表格Boolean-false
select-type选择列渲染的形式, radio或checkboxString-checkbox
row-key行数据的 Key,用来优化 Table 的渲染Functionrow, rowIndexrowIndex
row-class-name额外的表格行的类名String, Functionrow, rowIndex-
cell-class-name额外的表格行的类名String, Functionrow, rowIndex, column, columnIndex-
row-style额外的表格行的样式Object, Functionrow, rowIndex-
cell-style额外的表格单元格的样式Object, Functionrow, rowIndex, column, columnIndex-

Columns Configs

属性说明类型默认值
title列标题名称String''
key对应列内容的属性名String''
align对应列内容的对齐方式,可选值有 'center', 'right'String'left'
headerAlign对应列标题的对齐方式,可选值有 'center', 'right'String'left'
width列宽度String, Number'auto'
minWidth列最小宽度String, Number'80px'
type列类型,可选值有 'template'(自定义列模板)String''
template列类型为 'template'(自定义列模板) 时,对应的作用域插槽(它可以获取到 row, rowIndex, column, columnIndex)名称String''

Table Events

事件名说明参数
cell-click单击某一单元格row, rowIndex, column, columnIndex, $event
cell-dblclick双击某一单元格row, rowIndex, column, columnIndex, $event
cell-contextmenu在某一单元格上点击鼠标右键row, rowIndex, column, columnIndex, $event
cell-mouseenter鼠标滑入某一单元格row, rowIndex, column, columnIndex, $event
cell-mouseleave鼠标滑出某一单元格row, rowIndex, column, columnIndex, $event
row-click单击某一行row, rowIndex, $event
row-dblclick双击某一行row, rowIndex, $event
row-contextmenu在某一行上点击鼠标右键row, rowIndex, $event
row-mouseenter鼠标滑入某一行row, rowIndex, $event
row-mouseleave鼠标滑出某一行row, rowIndex, $event
checkbox-click鼠标单击checkboxrow, rowIndex, $event
tree-icon-click鼠标单击树形iconrow, rowIndex, $event
expand-cell-click鼠标单击展开单元格row, rowIndex, $event

Table Methods

方法名说明参数
getCheckedProp当表格为多选类型表格时,用于获取当前所选项的属性,返回一个数组;属性默认为'index'。prop