vueuse-components-skilld by harlan-zw/vue-ecosystem-skills
npx skills add https://github.com/harlan-zw/vue-ecosystem-skills --skill vueuse-components-skilld@vueuse/components用于 VueUse 的无渲染组件
版本: 14.2.1 依赖: @vueuse/shared@14.2.1, @vueuse/core@14.2.1 标签: next: 5.0.0, alpha: 14.0.0-alpha.3, beta: 14.0.0-beta.1, latest: 14.2.1
参考: GitHub Issues — 错误、变通方案、边界情况 • GitHub Discussions — 问答、模式、示例 • Releases — 变更日志、破坏性变更、新 API
本节记录了 @vueuse/components 特定版本的 API 变更 — 请优先关注近期的主要/次要版本。
破坏性变更: @vueuse/components v14+ 需要 Vue 3.5+,遵循核心库要求 来源
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
破坏性变更: 在 v14.0.0 中重构了无渲染组件以保持一致性。像 OnClickOutside 和 OnLongPress 这样的组件现在使用 options 属性进行配置,并使用 @trigger 事件来触发操作 来源
破坏性变更: 仅支持 ESM 的包 — 自 v13.0.0 起已放弃 CJS 构建 来源
已弃用: VOnClickOutside 已被弃用,推荐使用小写的 vOnClickOutside 指令 来源
已弃用: VOnLongPress 已被弃用,推荐使用小写的 vOnLongPress 指令 来源
新增: UseDraggable 在 v14.2.0 中支持 autoScroll 和 restrictInView 选项,用于受限拖拽 来源
新增: UseDraggable 支持 storageKey 和 storageType 属性,用于持久化元素位置 来源
新增: 添加了 vOnKeyStroke 指令,用于直接在元素上监听键盘事件
新增: UseIdle 的默认插槽数据现在通过 Stoppable 实现包含了 pause 和 resume 方法 来源
新增: vInfiniteScroll 在 v14.1.0 中支持响应式的 canLoadMore 选项 来源
新增: UseElementVisibility 在 v14.1.0 中添加了 initialValue 选项 来源
新增: UseMouseInElement 在 v14.1.0 中支持跟踪行内级元素 来源
新增: vIntersectionObserver 在 v14.2.0 中现在支持响应式的 rootMargin 选项 来源
新增: UseOffsetPagination 触发 page-change、page-size-change 和 page-count-change 事件
其他变更: useTransition 自定义插值器 · refManualReset 新函数 · tryOnScopeDispose 静默失败 · useAsyncState 执行结果 · useTimeAgoIntl 自定义单位
在 <UseDraggable> 组件上使用 storage-key 和 storage-type 属性,以在会话之间自动将元素位置持久化到 localStorage 或 sessionStorage 中 来源
在 OnClickOutside(组件或指令)中使用 ignore 选项,传递一个 ref 数组或 CSS 选择器,用于指定不应触发处理程序的元素,这对于像嵌套模态框这样的复杂 UI 至关重要 来源
始终在 <UseImage> 中提供 #loading 和 #error 插槽,以防止布局偏移并优雅地处理损坏的图像,而不是在脚本中手动管理加载状态 来源
优先使用 createReusableTemplate 而不是将小的、重复的 UI 片段提取到单独的文件中,以保持对局部作用域变量的访问,并避免繁琐的 prop/emit 定义 来源
为 createReusableTemplate<T>() 提供泛型类型,以启用完整的 TypeScript 支持和 IDE 自动补全,用于在 DefineTemplate 和 ReuseTemplate 之间传递的数据 来源
使用 createTemplatePromise 将复杂的 UI 元素(如模态框或对话框)作为 Promise 调用,将 UI 定义保留在模板中,同时保持程序化控制和清晰的 async/await 流程 来源
使用 [handler, options] 数组语法配置 @vueuse/components 指令,如 v-on-click-outside 或 v-on-long-press,以实现简洁的内联逻辑,而无需为选项单独设置变量 来源
使用 <UseOffsetPagination> 组件来处理复杂的分页状态;它触发清晰的事件(page-change、page-size-change),这些事件比手动监听 ref 更符合习惯,并且更容易在模板中连接 来源
在构建全局导航或模态框时,在 onClickOutside 选项中设置 detectIframe: true,以确保当用户点击 iframe 内部时它们会关闭,这是在手动实现中经常被忽略的边缘情况 来源
在可渲染组件(如 <UseElementBounding> 或 <UseFullscreen>)上使用 as 属性,将它们渲染为语义正确的 HTML 元素(例如 section、nav),而不是默认的 div 来源
每周安装数
77
代码仓库
GitHub 星标数
150
首次出现
2026年2月19日
安全审计
安装于
github-copilot60
opencode57
gemini-cli55
claude-code55
codex55
amp54
@vueuse/componentsRenderless components for VueUse
Version: 14.2.1 Deps: @vueuse/shared@14.2.1, @vueuse/core@14.2.1 Tags: next: 5.0.0, alpha: 14.0.0-alpha.3, beta: 14.0.0-beta.1, latest: 14.2.1
References: GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
This section documents version-specific API changes for @vueuse/components — prioritize recent major/minor releases.
BREAKING: @vueuse/components v14+ requires Vue 3.5+, following core library requirements source
BREAKING: Renderless components refactored for consistency in v14.0.0. Components like OnClickOutside and OnLongPress now use an options prop for configuration and @trigger emit for actions source
BREAKING: ESM-only package — CJS build has been dropped since v13.0.0 source
DEPRECATED: VOnClickOutside is deprecated in favor of the lowercase vOnClickOutside directive source
DEPRECATED: VOnLongPress is deprecated in favor of the lowercase vOnLongPress directive source
NEW: UseDraggable supports autoScroll and restrictInView options for constrained dragging in v14.2.0 source
NEW: UseDraggable supports storageKey and storageType props for persistent element position source
NEW: vOnKeyStroke directive added for listening to keyboard events directly on elements
NEW: UseIdle default slot data now includes pause and resume methods via Stoppable implementation source
NEW: vInfiniteScroll supports reactive canLoadMore option in v14.1.0 source
NEW: UseElementVisibility added initialValue option in v14.1.0 source
NEW: UseMouseInElement supports tracking inline-level elements in v14.1.0 source
NEW: vIntersectionObserver now supports reactive rootMargin option in v14.2.0 source
NEW: UseOffsetPagination emits page-change, page-size-change, and page-count-change events
Also changed: useTransition custom interpolators · refManualReset new function · tryOnScopeDispose failSilently · useAsyncState execute result · useTimeAgoIntl custom units
Use the storage-key and storage-type props on the <UseDraggable> component to automatically persist element position in localStorage or sessionStorage across sessions source
Utilize the ignore option in OnClickOutside (component or directive) to pass an array of refs or CSS selectors for elements that should not trigger the handler, essential for complex UIs like nested modals source
Always provide #loading and slots in to prevent layout shifts and handle broken images gracefully, rather than managing loading states manually in the script
Weekly Installs
77
Repository
GitHub Stars
150
First Seen
Feb 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot60
opencode57
gemini-cli55
claude-code55
codex55
amp54
前端开发AI工具 | 5大专业能力构建生产级前端页面 | 设计工程与动效系统
759 周安装
#error<UseImage>Prefer createReusableTemplate over extracting small, repeated UI fragments into separate files to maintain access to local scope variables and avoid tedious prop/emit definitions source
Provide a generic type to createReusableTemplate<T>() to enable full TypeScript support and IDE autocompletion for data passed between DefineTemplate and ReuseTemplate source
Use createTemplatePromise to call complex UI elements like modals or dialogs as promises, keeping the UI definition in the template while maintaining programmatic control and clean async/await flows source
Configure @vueuse/components directives like v-on-click-outside or v-on-long-press using the [handler, options] array syntax for clean, inline logic without needing a separate setup variable for options source
Use the <UseOffsetPagination> component to handle complex pagination state; it emits clean events (page-change, page-size-change) that are more idiomatic and easier to wire up in templates than manually watching refs source
Set detectIframe: true in onClickOutside options when building global navigation or modals to ensure they close when the user clicks inside an iframe, an edge case often missed in manual implementations source
Utilize the as prop on renderable components like <UseElementBounding> or <UseFullscreen> to render them as semantically correct HTML elements (e.g., section, nav) instead of the default div source