vueuse-motion-skilld by harlan-zw/vue-ecosystem-skills
npx skills add https://github.com/harlan-zw/vue-ecosystem-skills --skill vueuse-motion-skilld@vueuse/motion让您的组件动起来的 Vue 组合式函数
版本: 3.0.3 依赖: @vueuse/core@^13.0.0, @vueuse/shared@^13.0.0, defu@^6.1.4, framesync@^6.1.2, popmotion@^11.0.5, style-value-types@^5.1.2 标签: beta: 2.0.0-beta.29, latest: 3.0.3
参考: GitHub Issues — 错误、变通方案、边界情况 • GitHub Discussions — 问答、模式、配方 • Releases — 更新日志、破坏性变更、新 API
本节记录特定版本的 API 变更 — 优先关注近期的主要/次要版本。
破坏性变更: 仅支持 ESM — @vueuse/motion v3.0.0 移除了对 CommonJS (CJS) 的支持,该包现在仅支持 ESM 来源
新增: VueUse v13 支持 — 更新了依赖项以在 v3.0.0 中支持最新的 VueUse 功能
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
新增: <Motion> 组件 — 用于动画的声明式组件,自 v2.2.0 起提供更好的 SSR 和 MDC 支持 来源
新增: <MotionGroup> 组件 — 在 v2.2.0 中引入的无渲染组件,用于将运动配置应用于所有子元素 来源
新增: duration 和 delay 简写属性 — 自 v2.2.0 起支持直接在元素/组件上设置过渡时序 来源
破坏性变更: 放弃 Vue 2 支持 — v2.0.0 及以上版本仅支持 Vue 3 来源
新增: 完整的 SSR 支持 — 在 v2.0.0 中显著改善了组件和指令的服务器端渲染兼容性 来源
新增: 短横线命名法指令支持 — v-motion-initial 和其他指令变体自 v2.1.0 起支持短横线命名法 来源
新增: useMotionFeatures 导出 — 自 v2.2.6 起,此组合式函数已导出用于手动功能注册 来源
新增: useMotion 动态键 — 自 v2.1.0 起,在调用 .apply() 和其他方法时支持动态变体键 来源
新增: reactive-style 和 reactive-transform — 自 v2.0.0 起用于直接操作样式和变换的专用组合式函数 来源
新增: MotionPlugin 类型 — 在 v2.2.5 中增强了主 Vue 插件的 TypeScript 定义 来源
破坏性变更: onComplete 触发时机 — 在 v2.2.0 中修复,现在会在每个属性动画完成后触发,而不是仅触发一次 来源
新增: unref 指令绑定 — 指令现在会对初始绑定进行解引用,自 v2.0.0 起支持对象内的 refs 来源
其他变更: visibilityOnce 变体新增于 v2.0.0 · useSpring 文档更新于 v2.2.0 · preset 突变修复于 v2.2.0 · useMotions 动态键支持于 v2.1.0 · useMotionVariants 内部更新于 v2.0.0
避免在 setup 的顶层解构 useMotions(),因为属性是在脚本执行后注册的;应在方法或钩子中通过返回的对象访问它们以确保响应性 来源
// 推荐 const motions = useMotions() const play = () => motions.myElement?.variant.value = 'play'
// 避免 const { myElement } = useMotions()
在 Nuxt 3 模板中对可见性变体使用驼峰式命名(例如 visibleOnce)而非短横线命名(visible-once),以确保指令正确解析并避免警告 来源
对于需要健壮 SSR 的项目,优先使用 <Motion> 组件而非 v-motion 指令,因为它能更可靠地处理初始状态样式注入,有利于 SEO 和用户体验 来源
在 MotionPlugin 配置中定义自定义指令,以创建可复用的动画预设,这些预设可以通过 v-motion-[name] 在整个应用程序中一致地应用 来源
使用 <MotionGroup> 将单个动画配置或预设应用于多个子元素,从而显著减少模板样板代码并提高可维护性 来源
将运动实例中的 leave 辅助函数映射到 Vue <transition> 元素的 @leave 事件,以在元素上执行手动且同步的退出动画 来源
const { leave } = useMotion(target, { leave: { opacity: 0 } })
// 在模板中 // <transition @leave="(el, done) => leave(done)">
始终指定一个包含所有将被动画化的属性的 initial 变体,以防止意外的布局偏移,并确保从已知的基础状态平滑过渡 来源
将 useSpring 与 useMotionProperties 结合使用,以实现高性能、与帧率无关且需要物理连续性的动画,例如用于交互式手势 来源
在 Nuxt 应用程序中,使用 runtimeConfig.public.motion.directives 来定义全局自定义指令,确保它们在客户端和服务器渲染期间都能正确初始化 来源
将一个响应式引用作为 target 传递给 useMotion,以允许运动实例在元素更新时自动跟踪新元素并应用当前变体 来源
每周安装量
69
代码仓库
GitHub 星标数
147
首次出现
2026年2月19日
安全审计
已安装于
claude-code51
github-copilot50
codex46
opencode46
gemini-cli45
amp44
@vueuse/motionVue Composables putting your components in motion
Version: 3.0.3 Deps: @vueuse/core@^13.0.0, @vueuse/shared@^13.0.0, defu@^6.1.4, framesync@^6.1.2, popmotion@^11.0.5, style-value-types@^5.1.2 Tags: beta: 2.0.0-beta.29, latest: 3.0.3
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 — prioritize recent major/minor releases.
BREAKING: ESM-only — @vueuse/motion v3.0.0 dropped CommonJS (CJS) support, the package is now ESM-only source
NEW: VueUse v13 support — updated dependencies to support the latest VueUse features in v3.0.0 source
NEW: <Motion> component — declarative component for animations, offering better SSR and MDC support since v2.2.0 source
NEW: <MotionGroup> component — renderless component introduced in v2.2.0 to apply motion configurations to all child elements source
NEW: duration and delay shorthand props — support for setting transition timing directly on elements/components since v2.2.0 source
BREAKING: Drop Vue 2 support — v2.0.0 and above exclusively support Vue 3 source
NEW: Full SSR support — significantly improved server-side rendering compatibility for both components and directives in v2.0.0 source
NEW: kebab-case directive support — v-motion-initial and other directive variants now support kebab-case since v2.1.0 source
NEW: useMotionFeatures export — this composable is now exported for manual feature registration since v2.2.6 source
NEW: useMotion dynamic keys — support for dynamic variant keys when calling .apply() and other methods since v2.1.0 source
NEW: reactive-style and reactive-transform — specialized composables for direct style and transform manipulation since v2.0.0 source
NEW: MotionPlugin types — enhanced TypeScript definitions for the main Vue plugin in v2.2.5 source
BREAKING: onComplete triggers — fixed in v2.2.0 to trigger after each property animation completes instead of only once source
NEW: unref directive bindings — directives now unref initial bindings, supporting refs within objects since v2.0.0 source
Also changed: visibilityOnce variant new v2.0.0 · useSpring documentation update v2.2.0 · preset mutation fix v2.2.0 · useMotions dynamic keys v2.1.0 · useMotionVariants internal updates v2.0.0
Avoid deconstructing useMotions() at the top level of setup because properties are registered after the script execution; access them via the returned object within methods or hooks to ensure reactivity source
// Preferred const motions = useMotions() const play = () => motions.myElement?.variant.value = 'play'
// Avoid const { myElement } = useMotions()
Use camelCase for visibility variants in Nuxt 3 templates (e.g., visibleOnce) rather than kebab-case (visible-once) to ensure proper directive resolution and avoid warnings source
Prefer the <Motion> component over the v-motion directive for projects requiring robust SSR, as it handles initial state style injection more reliably for SEO and UX source
Weekly Installs
69
Repository
GitHub Stars
147
First Seen
Feb 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code51
github-copilot50
codex46
opencode46
gemini-cli45
amp44
开发者幻灯片技能:使用Slidev创建技术演示文稿,支持实时代码和图表
426 周安装
Define custom directives in the MotionPlugin configuration to create reusable animation presets that can be applied consistently via v-motion-[name] across the application source
Use <MotionGroup> to apply a single animation configuration or preset to multiple child elements, significantly reducing template boilerplate and improving maintainability source
Map the leave helper from the motion instance to the Vue <transition> element's @leave event to perform manual and synchronized exit animations on elements source
const { leave } = useMotion(target, { leave: { opacity: 0 } })
// In template // <transition @leave="(el, done) => leave(done)">
Always specify an initial variant containing all properties that will be animated to prevent unexpected layout shifts and ensure smooth transitions from a known base state source
Utilize useSpring with useMotionProperties for high-performance, frame-rate independent animations that require physical continuity, such as for interactive gestures source
In Nuxt applications, use runtimeConfig.public.motion.directives to define global custom directives, ensuring they are properly initialized during both client and server rendering source
Pass a reactive reference as the target to useMotion to allow the motion instance to automatically track and apply the current variant to new elements as they are updated source