@bhplugin/vue3-datatable

中文文档
3.0.0发布于 2026/04/16MITTypeScriptESM + CJS零依赖近 30 天下载 1.7万

Vue3 Datatable - fully customizable & easy to use datatable library

原始使用文档
文档目录19 节
  1. Example
  2. Install
  3. Usage
  4. Props
  5. columnFilterLang keys
  6. Column Definition
  7. Events
  8. Event rules
  9. Methods
  10. Slots
  11. Custom cell rendering (named by column field)
  12. Pagination arrow slots
  13. Empty state slot
  14. Server Mode Example
  15. Changelogs
  16. License
  17. Our other plugins
  18. Angular Datatable - @bhplugin/ng-datatable
  19. Support

@bhplugin/vue3-datatable

A zero-dependency Vue 3 datatable component with client/server-side pagination, sorting, filtering, row selection, and custom cell rendering.

Example

Document & Demos

Install

NPM

npm install @bhplugin/vue3-datatable --save

Yarn

yarn add @bhplugin/vue3-datatable

Usage

<template>
    <vue3-datatable :rows="rows" :columns="cols" :sortable="true" :columnFilter="true"> </vue3-datatable>
</template>

<script setup lang="ts">
    import { ref } from "vue";
    import Vue3Datatable from "@bhplugin/vue3-datatable";
    import type { IColumnDefinition } from "@bhplugin/vue3-datatable";
    import "@bhplugin/vue3-datatable/dist/style.css";

    const cols = ref<IColumnDefinition[]>([
        { field: "id", title: "ID", isUnique: true, type: "number", filter: false },
        { field: "name", title: "Name" },
        { field: "email", title: "Email" },
        { field: "age", title: "Age", type: "number" },
        { field: "dob", title: "Date of Birth", type: "date" },
        { field: "isActive", title: "Active", type: "bool" },
        { field: "address.city", title: "City" },
    ]);

    const rows = ref<Array<Record<string, unknown>>>([
        { id: 1, name: "John Doe", email: "[email protected]", age: 28, dob: "1997-05-15", isActive: true, address: { city: "New York" } },
        { id: 2, name: "Jane Smith", email: "[email protected]", age: 34, dob: "1991-11-22", isActive: false, address: { city: "London" } },
        // ...
    ]);
</script>

Props

PropTypeDefaultDescription
columns (required)IColumnDefinition[][]Table column definitions
rows (required)Record[][]Table row data
isServerModebooleanfalseEnable server-side mode (disables client-side sort/filter/pagination)
totalRowsnumber0Total row count (required in server mode)
skinstring"bh-table-striped bh-table-hover"Table skin classes: bh-table-striped, bh-table-hover, bh-table-bordered, bh-table-compact
loadingbooleanfalseShow loading overlay/skeleton
hasCheckboxbooleanfalseShow checkbox column for row selection
searchstring""Global search string
pagenumber1Current page (1-based)
pageSizenumber10Rows per page
pageSizeOptionsnumber[][10, 20, 30, 50, 100]Page size dropdown options
showPageSizebooleantrueShow page size dropdown
rowClassstring | Function""Custom row class (string or (row) => string)
cellClassstring | Function""Custom cell class (string or (row) => string)
sortablebooleanfalseEnable column sorting
sortColumnstring""Initial sort column field
sortDirection'asc' | 'desc'"asc"Initial sort direction
columnFilterbooleanfalseEnable per-column filter inputs
columnFilterLangRecord<string, string>nulli18n labels for filter conditions (see below)
paginationbooleantrueShow pagination
showNumbersbooleantrueShow page number buttons
showNumbersCountnumber5Max visible page number buttons
showFirstPagebooleantrueShow first page button
showLastPagebooleantrueShow last page button
paginationInfostring"Showing {0} to {1} of {2} entries"Pagination info template ({0} = start, {1} = end, {2} = total)
noDataContentstring"No data available"Empty state text
skeletonRowCountnumber10Number of skeleton rows while loading
stickyHeaderbooleanfalseSticky table header
heightstring"500px"Scrollable height (only with stickyHeader)
stickyFirstColumnbooleanfalseSticky first column
cloneHeaderInFooterbooleanfalseClone header as footer row
selectRowOnClickbooleanfalseToggle row selection on row click

columnFilterLang keys

{
    no_filter: 'No filter',
    contain: 'Contain', not_contain: 'Not contain',
    equal: 'Equal', not_equal: 'Not equal',
    start_with: 'Starts with', end_with: 'Ends with',
    greater_than: 'Greater than', greater_than_equal: 'Greater than or equal',
    less_than: 'Less than', less_than_equal: 'Less than or equal',
    is_null: 'Is null', is_not_null: 'Not null',
    all: 'All', true: 'True', false: 'False'   // boolean column filter labels
}

Column Definition

PropTypeDefaultDescription
isUniquebooleanfalseMark as unique row identifier (used for selection keys)
fieldstring""Data field path (supports dot notation: address.city)
titlestring""Column header text
valuestring""Initial filter value
conditionIFilterCondition""Default filter condition (contain for string, equal for number/date, empty for bool)
typestring"string"Column type: string, number, date, bool
widthstring""Column width (e.g., "200px")
minWidthstring""Minimum column width
maxWidthstring""Maximum column width
hidebooleanfalseHide column from rendering
filterbooleantrueEnable column filter
searchbooleantrueInclude in global search
sortbooleantrueEnable sorting
htmlbooleanfalseColumn contains raw HTML
cellRendererFunction-Custom cell renderer: (row) => '<strong>html</strong>' (sanitized automatically)
headerClassstring""Custom header cell class
cellClassstring""Custom body cell class

Events

EventPayloadDescription
changeServerIServerChangeResponseServer mode only — aggregate event with full state (page, sort, search, filters, change_type)
pageChangenumberUser clicked pagination button (silent on programmatic resets)
pageSizeChangenumberPage size dropdown changed
sortChangeISortChangeResponseColumn sort applied (does NOT reset page)
filterChangeIColumnDefinition[]Column filter value or condition changed
searchChangestringGlobal search prop changed
rowSelectRecord[]Row selection changed (user interaction only)
rowClickRecordRow single click
rowDBClickRecordRow double click
reset-reset() called — only event during reset, all others suppressed

Event rules

  • Sort does not reset page
  • Filter/search/pagesize resets to page 1 but only emits the specific event (not pageChange)
  • pageChange fires only from explicit user pagination clicks
  • During reset, only reset (+ changeServer in server mode) emits — all other events suppressed

Methods

MethodDescription
reset()Reset all state (selection, filters, search, sort, page)
getFilteredRows()Returns all filtered rows
getVisibleRows()Returns current page visible rows
getColumnFilters()Returns column definitions with current filter state
getSelectedRows()Returns all selected rows
clearSelectedRows()Deselect all rows
selectRow(index)Select row by index
unselectRow(index)Deselect row by index
isRowSelected(index)Check if row is selected

Slots

Custom cell rendering (named by column field)

<vue3-datatable :rows="rows" :columns="cols">
    <template #name="{ value }">
        <strong>{{ value.name }}</strong>
    </template>
</vue3-datatable>

Pagination arrow slots

<template #firstArrow> &laquo; </template>
<template #previousArrow> &lsaquo; </template>
<template #nextArrow> &rsaquo; </template>
<template #lastArrow> &raquo; </template>

Empty state slot

<template #noData>
    <div>No records found.</div>
</template>

Server Mode Example

<vue3-datatable
    :rows="rows"
    :columns="cols"
    :loading="loading"
    :totalRows="totalRows"
    :isServerMode="true"
    :pageSize="10"
    :sortable="true"
    :columnFilter="true"
    @page-change="onPageChange"
    @page-size-change="onPageSizeChange"
    @sort-change="onSortChange"
    @filter-change="onFilterChange"
    @search-change="onSearchChange"
/>

Changelogs

Changelogs

License

@bhplugin/vue3-datatable is open-sourced software licensed under the MIT license.

Our other plugins

Angular Datatable - @bhplugin/ng-datatable

Support

Buy Me A Coffee

版本与发布记录

@bhplugin/vue3-datatable 共发布 33 个版本,首次发布于 2022/11/13;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.0.0latest2026/04/166 个月前
2.0.22025/03/021.7 年前
2.0.12025/01/301.8 年前
2.0.02024/09/282 年前
1.1.42024/02/082 年前
1.1.32023/11/063 年前

关于 @bhplugin/vue3-datatable 的常见问题

@bhplugin/vue3-datatable 是什么?

Vue3 Datatable - fully customizable & easy to use datatable library

如何安装 @bhplugin/vue3-datatable?

在项目目录运行 npm install @bhplugin/vue3-datatable,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(>=3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bhplugin/vue3-datatable 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bhplugin/vue3-datatable 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bhplugin/vue3-datatable 可以商用吗?

@bhplugin/vue3-datatable 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bhplugin/vue3-datatable 的下载量有多少?

根据 npm 官方下载统计,@bhplugin/vue3-datatable 在 2026/10/08 – 2026/11/06 这 30 天内被下载 16,619 次,日均约 554 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bhplugin/vue3-datatable 还在维护吗?

最新版本 3.0.0 发布于 2026/04/16(6 个月前);至今共发布 33 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/11/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。