mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
5.0 KiB
5.0 KiB
vxe-table
A very powerful Vue table component.
Browser Support
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| 11+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
Features
- 基础
- 尺寸
- 斑马线条纹
- 带边框
- 单元格样式
- 列宽拖动
- 流体高度
- 响应式宽高
- 固定表头
- 固定列
- 固定表头和列
- 表头分组
- 序号
- 单选
- 多选
- 排序
- 筛选
- 合并行或列
- 表尾合计
- 导出 CSV
- 显示/隐藏列
- 加载中
- 格式化内容
- 自定义模板
- 快捷菜单
- 可视渲染
- 展开行
- 分页
- 工具栏
- 树形表格
- 增删改查
- 数据校验
- 数据代理
- 全键盘操作
- Excel 表格
Docs
Installing
require: Vue 2.6+
npm install xe-utils vxe-table
<!-- 引入样式 -->
<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'
import 'vxe-table/lib/index.css'
Vue.use(VXETable)
Global config
import Vue from 'vue'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
Vue.use(VXETable, {
size: 'small'
})
Theme
Case 1. 默认的样式
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
Case 2. 自定义表格颜色(修改局部颜色变量)
// 引入变量
@import 'vxe-table/src/style/variable.scss';
// 局部覆盖
$vxe-font-color: #606266;
$vxe-table-header-background-color: #f8f8f9;
$vxe-table-border-color: #e8eaec;
$vxe-table-background-color: #ffffff;
// 引入样式
@import 'vxe-table/src/style/default.scss';
Case 3. 重写主题样式,复制 vxe-table/src/style 目录到项目中自行修改就行(例如复制到 /assets)
@import 'assets/style/index.scss';
I18n
import Vue from 'vue'
import VueI18n from 'vxe-i18n'
import VXETable from 'vxe-table'
import zhCNLocat from 'vxe-table/lib/locale/lang/zh_CN'
import enLocat from 'vxe-table/lib/locale/lang/zh_CN'
const messages = {
zh_CN: {
...zhCNLocat
},
en: {
...enLocat
}
}
const i18n = new VueI18n({
locale: 'zh_CN',
messages,
})
Vue.use(VXETable, {
i18n: (key, value) => i18n.t(key, value)
})
new Vue({ i18n }).$mount('#app')
Plugins
- vxe-table-plugin-element 用于适配 element-ui 组件
- vxe-table-plugin-iview 用于适配 iview 组件
Example
<template>
<div>
<vxe-table ref="xTable" :data.sync="tableData">
<vxe-table-column type="index" label="Number" width="80"></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,
name: 'test1',
role: 'developer',
sex: 'Man',
address: 'address abc123'
}
]
}
}
}
</script>
License
Copyright (c) 2019-present, Xu Liangzhan





