New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vxe-table

Package Overview
Dependencies
Maintainers
1
Versions
2020
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vxe-table

A very powerful Vue table component.

  • 0.0.1-beta.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
increased by119.59%
Maintainers
1
Weekly downloads
 
Created
Source

vxe-table

npm version npm downloads gzip size: JS gzip size: CSS npm license

A very powerful Vue table component.

Features

Installing

npm install xe-utils vxe-table

Get on unpkg and cdnjs

<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/vxe-table/lib/index.css">
<!-- 引入脚本 -->
<script src="https://unpkg.com/xe-utils"></script>
<script src="https://unpkg.com/vxe-table"></script>
import Vue from 'vue'
import VXETable from 'vxe-table'

// Case 1. 引入默认的样式
import 'vxe-table/lib/index.css'

// Case 2. 自定义表格颜色(复制 style/variable.scss 到自己的项目中,修改颜色变量,然后引入)
// @import 'assets/style/vxe-table/variable.scss';
// @import 'vxe-table/style/table.scss';

// Case 3. 重写主题样式(复制 style/table.scss 到项目中自行修改)
// @import 'assets/style/vxe-table/variable.scss';
// @import 'assets/style/vxe-table/table.scss';

Vue.use(VXETable)

// 支持设置全部默认参数
// Vue.use(VXETable, {
//   size: 'small, // 默认表格尺寸
//   optimized: false, // 默认优化配置项
//   contextMenu: null // 默认快捷菜单
// })

API

Table

<vxe-table :data.sync="tableData">
  <vxe-table-column type="selection" width="60"></vxe-table-column>
  <vxe-table-column prop="name" label="Name"></vxe-table-column>
  <vxe-table-column prop="address" label="Address"></vxe-table-column>
</vxe-table>
Table Attributes
参数说明类型可选值默认值
data显示的数据Array
customs初始化绑定动态列Array
height表格的高度Number
maxHeight表格的最大高度Number
stripe是否带有斑马纹Booleanfalse
border是否带有纵向边框Booleanfalse
size表格的尺寸Stringmedium / small / mini
fit列的宽度是否自撑开Booleantrue
loading表格是否加载中Booleanfalse
show-header是否显示表头Booleantrue
highlight-current-row是否要高亮当前选中行Booleanfalse
highlight-hover-row鼠标移到行是否要高亮显示Booleantrue
row-class-name给行附加 className,也可以是函数 Function({row, rowIndex})String/Function
cell-class-name给单元格附加 className,也可以是函数 Function({row, rowIndex, column, columnIndex})String/Function
header-row-class-name给表头的行附加 className,也可以是函数 Function({row, rowIndex})String/Function
header-cell-class-name给表头的单元格附加 className,也可以是函数 Function({row, rowIndex, column, columnIndex})String/Function
context-menu快捷菜单配置Object{header, body}
row-key行数据的 KeyString
auto-width自动计算列宽(如果关闭,需要手动调用 computeWidth 方法)Booleantrue
optimized优化的配置项Object/Boolean{animat: true, overflow: 'title'}

快捷菜单配置项说明(配合 context-menu-link 事件使用):

属性描述类型参数
disabled是否禁用表格头部右键Boolean
options表格头部菜单配置Array{ code, name, prefixIcon, suffixIcon, disabled }
visibleMethod该函数 Function({row, rowIndex, column, columnIndex}, event) 的返回值用来决定是否允许显示右键菜单Function
Table Events
事件名说明参数
select-all只对 type=selection 有效,当手动勾选全选时触发的事件{selection,checked},event
select-change只对 type=selection/radio 有效,当手动勾选时触发的事件{selection,checked,row,column},event
cell-click当某个单元格被点击时会触发该事件{row,rowIndex,column,columnIndex,cell},event
cell-dblclick当某个单元格被双击时会触发该事件{row,rowIndex,column,columnIndex,cell},event
context-menu-link当点击上下文菜单后触发menu,event
Table Methods
方法名描述参数
reload初始化数据data
clearSelection用于多选表格,清空用户的选择
clearSelectRow用于单选表格,清空用户的选择
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter用于清空筛选条件,数据会恢复成未筛选的状态
computeWidth重新计算并更新列宽

Table-column

<vxe-table-column prop="name" label="Name"></vxe-table-column>
Table-column Attributes 参数
参数说明类型可选值默认值
type列的类型Stringindex / selection / radio
prop列属性String
label列标题String
width列宽度String
min-width最小列宽度,把剩余宽度按比例分配String
fixed将列固定在左侧或者右侧Stringleft
align列对其方式Stringleft
header-align表头对齐方式String
ellipsis当内容过长时显示为省略号Booleanfalse
show-overflow-title当内容过长显示为省略号并用原生的 title 显示完整内容Booleanfalse
show-overflow-tooltip当内容过长显示为省略号并用 tooltip 显示完整内容Booleanfalse
formatter格式化显示内容 Function({cellValue, row, rowIndex, column, columnIndex})Function
index-method只对 type=index 有效,自定义索引方法 Function({row, rowIndex, column, columnIndex})Function
sortable是否允许列排序Boolean
sortBy只对 sortable 有效,自定义排序的属性String/Array
filters配置筛选条件数组Array
filter-multiple只对 filters 有效,筛选是否允许多选Booleantrue
filter-method只对 filters 有效,自定义筛选方法 Function({value, row, column})Function
column-key列的 key[String, Number]
Table-column Scoped Slot
name说明
自定义显示内容,参数为 { row, rowIndex, column, columnIndex, fixed, isHidden }
header自定义表头的内容,参数为 { column, columnIndex, fixed, isHidden }

Example

<template>
  <div>
    <vxe-table :data.sync="tableData">
      <vxe-table-column type="index" width="60"></vxe-table-column>
      <vxe-table-column prop="name" label="Name"></vxe-table-column>
      <vxe-table-column prop="sex" label="Sex"></vxe-table-column>
      <vxe-table-column prop="address" label="Address"></vxe-table-column>
    </vxe-table>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [
        {
          id: 10001,
          checked: false,
          name: 'test1',
          role: 'developer',
          sex: 'Man',
          date: '2019-05-01',
          time: 1556677810888,
          region: 'ShenZhen',
          address: 'address abc123'
        }
      ]
    }
  }
}
</script>

License

Copyright (c) 2017-present, Xu Liangzhan

Keywords

FAQs

Package last updated on 29 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc