primevue-skilld
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseprimefaces/primevue primevue
primevueprimefaces/primevue primevue
primevueVersion: 4.5.4 (Dec 2025)
Deps: @primeuix/styled@^0.7.4, @primeuix/utils@^0.6.2, @primeuix/styles@^2.0.2, @primevue/core@4.5.4, @primevue/icons@4.5.4
Tags: v2-stable: 2.10.4 (Dec 2023), v3-stable: 3.53.1 (Dec 2024), latest: 4.5.4 (Dec 2025)
References: Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • Releases — changelog, breaking changes, new APIs
**版本:**4.5.4(2025年12月)
依赖:@primeuix/styled@^0.7.4、@primeuix/utils@^0.6.2、@primeuix/styles@^2.0.2、@primevue/core@4.5.4、@primevue/icons@4.5.4
**标签版本:**v2-stable: 2.10.4(2023年12月)、v3-stable: 3.53.1(2024年12月)、latest: 4.5.4(2025年12月)
参考资源:文档 — API参考、使用指南 • GitHub问题 — 问题反馈、解决方案、边缘场景 • 版本发布记录 — 更新日志、破坏性变更、新API
API Changes
API变更
This section documents version-specific API changes — prioritize recent major/minor releases.
-
BREAKING:renamed to
Calendar— v3 component renamed toDatePickerin v4 sourceDatePicker -
BREAKING:renamed to
Dropdown— v3 component renamed toSelectin v4 sourceSelect -
BREAKING:renamed to
Sidebar— v3 component renamed toDrawerin v4 sourceDrawer -
BREAKING:renamed to
OverlayPanel— v3 component renamed toPopoverin v4 sourcePopover -
BREAKING:renamed to
InputSwitch— v3 component renamed toToggleSwitchin v4 sourceToggleSwitch -
BREAKING:replaced by
TabView— new component structure usingTabs,TabList,Tab, andTabPanelssourceTabPanel -
BREAKING:replaced by
Steps— new component structure usingStepper,StepList,Step, andStepPanelssourceStepPanel -
BREAKING:reimplementation — now uses
Accordion,AccordionPanel, andAccordionHeadercomponents sourceAccordionContent -
BREAKING:— v4 uses
v-model:valuefor active state inv-model:value,Tabs, andAccordioninstead ofSteppersourcev-model -
DEPRECATED:— property replaced by
inputStyle(values: 'filled' | 'outlined') sourceinputVariant -
NEW:— new dedicated package for advanced form management and validation source
@primevue/forms -
NEW:component — layout component that makes descendants span full width source
Fluid -
NEW:&
IconField— new components to wrap inputs and icons for decorative purposes sourceInputIcon -
NEW:&
useId— new core composables for unique ID generation and attribute selectors sourceuseAttrSelector
Also changed: default is (v4.3.0) · new component for in-field labels · added state · new component replaces directive · component deprecated · removed from · property renamed to · added emit (v4.3.0)
DataTableshowClearButtonfalseIftaLabelCheckboxindeterminateOverlayBadgeBadgeInlineMessageiconPositionIconFieldwarningwarnDrawerbefore-hide本节记录特定版本的API变更——优先关注近期的主版本/次版本更新。
-
破坏性变更:重命名为
Calendar——v3版本的该组件在v4中更名为DatePicker来源DatePicker -
破坏性变更:重命名为
Dropdown——v3版本的该组件在v4中更名为Select来源Select -
破坏性变更:重命名为
Sidebar——v3版本的该组件在v4中更名为Drawer来源Drawer -
破坏性变更:重命名为
OverlayPanel——v3版本的该组件在v4中更名为Popover来源Popover -
破坏性变更:重命名为
InputSwitch——v3版本的该组件在v4中更名为ToggleSwitch来源ToggleSwitch -
破坏性变更:被
TabView替代 ——新组件结构使用Tabs、TabList、Tab和TabPanels来源TabPanel -
破坏性变更:被
Steps替代 ——新组件结构使用Stepper、StepList、Step和StepPanels来源StepPanel -
破坏性变更:重新实现 ——现在使用
Accordion、AccordionPanel和AccordionHeader组件 来源AccordionContent -
破坏性变更:——v4版本在
v-model:value、Tabs和Accordion中使用Stepper控制激活状态,替代原有的v-model:value来源v-model -
已废弃:——该属性被
inputStyle替代(可选值:'filled' | 'outlined') 来源inputVariant -
新增功能:——用于高级表单管理和验证的专属新包 来源
@primevue/forms -
新增组件:——使子元素撑满宽度的布局组件 来源
Fluid -
新增组件:&
IconField——用于包裹输入框和图标以实现装饰效果的新组件 来源InputIcon -
新增组合式函数:&
useId——用于生成唯一ID和属性选择器的核心新组合式函数 来源useAttrSelector
其他变更:的默认值改为(v4.3.0)·新增组件用于字段内标签·新增状态·新组件替代指令·组件已废弃·移除属性·属性重命名为·新增事件(v4.3.0)
DataTableshowClearButtonfalseIftaLabelCheckboxindeterminateOverlayBadgeBadgeInlineMessageIconFieldiconPositionwarningwarnDrawerbefore-hideBest Practices
最佳实践
- Use the component as a wrapper for bulk application of full-width styles to inputs instead of adding the
Fluidprop to every individual field for cleaner and more maintainable templates sourcefluid
vue
<Fluid>
<div class="grid grid-cols-2 gap-4">
<InputText placeholder="Full Width" />
<DatePicker placeholder="Full Width" />
<Select placeholder="Full Width" />
</div>
</Fluid>-
In Stepper vertical layouts, always wrapand
Stepinside aStepPanelcomponent to ensure correct structure and connection between headers and content sourceStepItem -
Useand
asChildon components likev-slotorStepto implement headless mode for full UI control while retaining PrimeVue's built-in accessibility logic sourceTab
vue
<Step v-slot="{ activateCallback, value, a11yAttrs }" asChild :value="1">
<button @click="activateCallback" v-bind="a11yAttrs.header">
Step {{ value }}
</button>
</Step>- For performant row expansion in with large datasets, use an object for
DataTablecombined withexpandedRowsinstead of an array of row objects sourcedataKey
ts
// Preferred (O(1) lookup)
const expandedRows = ref({ '1004': true, '1005': true });
// In template
<DataTable v-model:expandedRows="expandedRows" dataKey="id">-
Enable automatic user preference persistence (sorting, filtering, paging) inusing
DataTableandstateStorageto improve UX across page visits sourcestateKey -
Add ato
delayto throttle rendering during rapid scrolling, significantly improving UI responsiveness for extremely large lists sourceVirtualScroller
vue
<VirtualScroller :items="items" :itemSize="50" :delay="250">
<template v-slot:item="{ item }">{{ item }}</template>
</VirtualScroller>-
Implement semantic navigation menus by usingwithout
Tabsand combining it withTabPanelsfor accessible, state-aware top or side bars sourcerouter-link -
Always wrap inputs and icons withand
IconFieldto ensure correct positioning and styling, supporting both leading and trailing icon placements sourceInputIcon
vue
<IconField>
<InputIcon class="pi pi-search" />
<InputText placeholder="Search" />
</IconField>-
Usefor modern, top-aligned in-field labels that visually integrate with the input and handle validation states automatically source
IftaLabel -
Leverage the built-incontext menu integration to provide row-specific actions without manual event listener management or custom positioning logic source
DataTable
vue
<ContextMenu ref="cm" :model="menuModel" />
<DataTable :value="products" contextMenu @row-contextmenu="onRowContextMenu">- 使用组件作为容器,批量为输入框应用全宽样式,而非为每个单独字段添加
Fluid属性,以此获得更简洁、更易维护的模板 来源fluid
vue
<Fluid>
<div class="grid grid-cols-2 gap-4">
<InputText placeholder="Full Width" />
<DatePicker placeholder="Full Width" />
<Select placeholder="Full Width" />
</div>
</Fluid>-
在垂直布局的Stepper中,务必将和
Step包裹在StepPanel组件内,以确保头部和内容之间的结构正确且关联正常 来源StepItem -
在或
Step等组件上使用Tab和asChild实现无头模式,在完全控制UI的同时保留PrimeVue内置的无障碍访问逻辑 来源v-slot
vue
<Step v-slot="{ activateCallback, value, a11yAttrs }" asChild :value="1">
<button @click="activateCallback" v-bind="a11yAttrs.header">
Step {{ value }}
</button>
</Step>- 针对包含大量数据的实现高性能行展开功能,使用对象类型的
DataTable结合expandedRows,而非行对象数组 来源dataKey
ts
// 推荐方案(O(1)查找效率)
const expandedRows = ref({ '1004': true, '1005': true });
// 模板中使用
<DataTable v-model:expandedRows="expandedRows" dataKey="id">-
在中启用
DataTable和stateStorage,实现用户偏好(排序、筛选、分页)的自动持久化,提升跨页面访问的用户体验 来源stateKey -
为添加
VirtualScroller属性,在快速滚动时限制渲染频率,显著提升超大型列表的UI响应速度 来源delay
vue
<VirtualScroller :items="items" :itemSize="50" :delay="250">
<template v-slot:item="{ item }">{{ item }}</template>
</VirtualScroller>-
通过使用不带的
TabPanels并结合Tabs实现语义化导航菜单,打造具备无障碍访问能力、状态感知的顶部或侧边栏 来源router-link -
务必使用和
IconField包裹输入框和图标,确保图标定位和样式正确,支持前置和后置图标两种布局 来源InputIcon
vue
<IconField>
<InputIcon class="pi pi-search" />
<InputText placeholder="Search" />
</IconField>-
使用实现现代化的顶部对齐字段内标签,其可与输入框视觉整合并自动处理验证状态 来源
IftaLabel -
利用内置的右键菜单集成,提供行级专属操作,无需手动管理事件监听器或自定义定位逻辑 来源
DataTable
vue
<ContextMenu ref="cm" :model="menuModel" />
<DataTable :value="products" contextMenu @row-contextmenu="onRowContextMenu">