vue 生成 dom组件_具有虚拟dom的Vue表组件

vue 生成 dom组件

虚拟虚拟表 (vue-virtual-table)

Vue table component with virtual dom and easy api.

具有虚拟dom和简单api的Vue表组件。

  • Keep smooth when the data reachs thousands of rows or even more.

    当数据达到数千行甚至更多时,请保持平滑。

  • Easy to use with a simple config.

    易于使用,配置简单。

用法 (Usage)

A simplest example:

最简单的例子:

<template>
  <vue-virtual-table
    :config="tableConfig"
    :data="tableData"
  >
  </vue-virtual-table>
</template>

<script>
import VueVirtualTable from 'vue-virtual-table'
export default {
  components: {
    VueVirtualTable
  },
  data: {
    tableConfig: [
      {prop: 'user'},
      {prop: 'age'}
    ],
    tableData: [
      {user: 'a1', age: 20},
      {user: 'a2', age: 21},
      {user: 'a3', age: 23}
    ]
  }
}
</script>

Every item of the config refers to a column. When you don't set sepcific 'name' of the table column header, it will uses the 'prop' value as default. Or you can set the tableConfig like:

配置的每个项目都指向一列。 当您未设置表列标题的单独“名称”时,它将使用“ prop”值作为默认值。 或者您可以像这样设置tableConfig:

tableConfig: [
  { prop: "user", name: "User Name" },
  { prop: "age", name: "Age" }
];

And if you want to search in the 'user' column, set the tableConfig like:

如果要在“用户”列中进行搜索,请像下面这样设置tableConfig:

tableConfig: [
  { prop: "user", name: "User Name", searchable: true },
  { prop: "age", name: "Age" }
];

For the 'age' column which is a set of number, you'd better use 'numberFilter' to filter numbers with "<", ">", "between" etc.

对于由数字组成的“年龄”列,最好使用“ numberFilter”来过滤带有“ <”,“>”,“介于”等的数字。

tableConfig: [
  { prop: "user", name: "User Name", searchable: true },
  { prop: "age", name: "Age", numberFilter: true }
];

There are many convenient features hard to explain one by one. Here is a complex example and you can get more info in the tables below the example:

有许多便利的功能很难一一解释。 这是一个复杂的示例,您可以在示例下方的表中获取更多信息:

<template>
  <vue-virtual-table
    :config="tableConfig"
    :data="tableData"
    :height="800"
    :itemHeight="55"
    :minWidth="1000"
    :selectable="true"
    :enableExport="true"
    v-on:changeSelection="handleSelectionChange"
  >
    <template slot-scope="scope" slot="actionCommon">
      <button @click="edit(scope.index, scope.row)">Edit</button>
      <button @click="del(scope.index, scope.row)">Delete</button>
    </template>
  </vue-virtual-table>
</template>

<script>
import VueVirtualTable from 'vue-virtual-table'
export default {
  components: {
    VueVirtualTable
  },
  data: {
    tableConfig: [
      {prop: '_index', name: '#', width: 80},
      {prop: 'user', name: 'User', searchable: true, sortable: true, summary: 'COUNT'},
      {prop: 'age', name: 'Age', numberFilter: true},
      {prop: 'city', name: 'City', filterable: true},
      {prop: '_action', name: 'Action', actionName: 'actionCommon'}
    ],
    tableData: [
      {user: 'a1', age: 20, city: 'aaaa'},
      {user: 'a2', age: 21, city: 'bbbb'},
      {user: 'a3', age: 23, city: 'aaaa'}
    ]
  },
  methods: {
    handleSelectionChange(rows){
      console.log(rows)
    },
    edit(index, row){
      console.log(index)
    },
    del(index, row){
      console.log(index)
    }
  }
}
</script>

表格属性 (Table Attributes)

nametypedescriptionrequireddefault
dataArrayThe array of data. Every item is a row.Yes
configArrayThe config of table.Yes
minWidthNumberSet the minimum width of table.No1200px
heightNumberSet the height of table.No300px
itemHeightNumberSet the height of row.No42px
borderedBooleanWhether table has vertical border.Nofalse
hoverHighlightBooleanWhether to hightlight current row.Notrue
selectableBooleanWhether row is selectable.Nofalse
enableExportBooleanWhether to show export-to-table buttonNofalse
languageStringLanguage from ['en', 'cn']No'cn'
名称 类型 描述 需要 默认
数据 数组 数据数组。 每个项目都是一行。
配置 数组 表的配置。
minWidth 设置表格的最小宽度。 没有 1200像素
高度 设置桌子的高度。 没有 300像素
itemHeight 设置行的高度。 没有 42像素
接壤的 布尔型 表格是否有垂直边框。 没有
悬停亮点 布尔型 是否突出显示当前行。 没有 真正
可选择的 布尔型 行是否可选。 没有
enableExport 布尔型 是否显示导出到表格按钮 没有
语言 来自['en','cn']的语言 没有 'cn'

表事件 (Table Events)

nameparametersdescription
changeSelectionrowsWhen the selected rows change
名称 参数 描述
changeSelection 行数 当选定的行更改时

表配置 (Table Config)

paramtypedescriptionrequireddefault
propStringProperty nameYes
nameStringDisplay nameNosame to the property name
widthNumberColumn widthNoauto
sortableBooleanWhether this column is sortableNofalse
searchableBooleanWhether this column is searchableNofalse
filterableBooleanWhether this column is filterableNofalse
numberFilterBooleanIf it's a column of number. You can use this.Nofalse
summaryStringsummary type from ['COUNT', 'SUM'] or customize.No
prefixStringDisplay before the valueNo
suffixStringDisplay after the valueNo
alignItemsStringSame with flex. Control the content of a cellNocenter
isHiddenBooleanWhether this column is hiddenNofalse
参数 类型 描述 需要 默认
Struts 物业名称
名称 显示名称 没有 与属性名称相同
宽度 列宽 没有 汽车
可排序 布尔型 此列是否可排序 没有
可搜寻的 布尔型 此列是否可搜索 没有
可过滤的 布尔型 此列是否可过滤 没有
numberFilter 布尔型 如果是一列数字。 您可以使用它。 没有
摘要 [[COUNT],“ SUM”]中的摘要类型或自定义。 没有
字首 在值之前显示 没有
后缀 数值后显示 没有
alignItems 与flex相同。 控制单元格的内容 没有 中央
隐藏 布尔型 此列是否隐藏 没有

特殊道具 (Special Props)

namedescription
_indexShow the index of row
_actionA slot to customize the content
_expandA slot to customize a popover window
名称 描述
_指数 显示行的索引
_行动 定制内容的插槽
_扩大 用于自定义弹出窗口的插槽

翻译自: https://vuejsexamples.com/vue-table-component-with-virtual-dom/

vue 生成 dom组件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值