Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

custom-table

A custom-table component for vue. --base element-ui 2.3.2

Installation

npm i custom-table -D
or
yarn add custom-table -D
# if you need
yarn add element-theme-chalk -D

Usage

importVuefrom'vue'importCustomTablefrom'custom-table'Vue.use(CustomTable)// or// maybe you need to install element-theme-chalk as css styleimport'element-theme-chalk/lib/table.css'import'element-theme-chalk/lib/table-column.css'importVuefrom'vue'import{CustomTable,ExpendTable,CustomTableColumn,CustomTableWithSlot}from'custom-table'Vue.component(CustomTable.name,CustomTable)Vue.component(ExpendTable.name,ExpendTable)Vue.component(CustomTableColumn.name,CustomTableColumn)Vue.component(CustomTableWithSlot.name,CustomTableWithSlot)

Custom Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门

propsKey

参数说明类型可选值默认值
label指定表格数据 label 字段为 data 的某个属性值string'label'
children指定表格数据 children 字段为 data 的某个属性值string'children'

如果需要使用 custom-table-with-slotexpand mode,则只需在 data 中加入 children 字段及相关需要显示的数据即可。

Expand Table Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
props-keydata 数据指定的字段 keyObject传送门
expand-keys默认展开行的键值string[][]
left折叠按钮位置,列number1
width表格默认最少宽度number80
*row-key行数据的 key,保证唯一性string默认以 props 的第一个值的 prop 作为 key
其他el-table 指定可用 attributes传送门

Custom Table With Slot Attributes

参数说明类型可选值默认值
data表格数据any[][]
props表头数据any[]传送门[]
propsKey指定 data 数据的字段 keyObject传送门
其他el-table 指定可用 attributes传送门
Custom Table With Slot 注:

props 中 children 字段无效,slot 需配合 showSlot 字段使用。

Table

Table Attributes

参数说明类型可选值默认值
data显示的数据array
heightTable 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string/number
max-heightTable 的最大高度string/number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringmedium / small / mini
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性String,Number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/String
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。Function({row, rowIndex})/Object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。Function({row, column, rowIndex, columnIndex})/Object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。Function({row, rowIndex})/String
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。Function({row, rowIndex})/Object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。Function({row, rowIndex, rowIndex, columnIndex})/Object
row-key行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能的情况下,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 FunctionFunction(row)/String
empty-text空数据时显示的文本内容,也可以通过 slot="empty" 设置String暂无数据
default-expand-all是否默认展开所有行,当 Table 中存在 type="expand" 的 Column 的时候有效Booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。Array
default-sort默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序Objectorder: ascending, descending如果只指定了prop, 没有指定order, 则默认顺序是ascending
tooltip-effecttooltip effect 属性Stringdark/light
show-summary是否在表尾显示合计行Booleanfalse
sum-text合计行第一列的文本String合计
summary-method自定义的合计计算方法Function({ columns, data })
span-method合并行或列的计算方法Function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行Booleantrue

Table Events

事件名说明参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, event, column
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, event
row-dblclick当某一行被双击时会触发该事件row, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-change当表格的筛选条件发生变化的时候会触发该事件,参数的值是一个对象,对象的 key 是 column 的 columnKey,对应的 value 为用户选择的筛选条件的数组。filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件row, expandedRows

Table Methods

方法名说明参数
clearSelection用于多选表格,清空用户的选择
toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)row, selected
toggleRowExpansion用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expanded 为 true 则展开)row, expanded
setCurrentRow用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空过滤条件,数据会恢复成未过滤的状态
doLayout对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法

Todos

  • [] custom-table 也支持 expand mode

License

MIT

About

a custom table component for vue. -- base v2.2.2

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages