SKILL.md
readonly只读
name
vue-debug-guides
description
Vue 3 调试与错误处理,涵盖运行时错误、警告、异步失败以及 SSR/水合问题。在诊断或修复 Vue 问题时使用。
Vue 3 调试与错误处理,针对运行时问题、警告、异步失败和水合错误。
关于开发最佳实践和常见陷阱,请使用 vue-best-practices。
响应式
- 追踪意外的重新渲染和状态更新 → 参见 reactivity-debugging-hooks
- 由于缺少 .value 访问导致 ref 值不更新 → 参见 ref-value-access
- 解构响应式对象后状态停止更新 → 参见 reactive-destructuring
- 数组、Map 或 Set 中的 ref 未解包 → 参见 refs-in-collections-need-value
- 嵌套 ref 在模板中渲染为 [object Object] → 参见 template-ref-unwrapping-top-level
- 响应式代理身份比较始终返回 false → 参见 reactivity-proxy-identity-hazard
- 第三方实例在被代理时出现问题 → 参见 reactivity-markraw-for-non-reactive
- 观察者意外地每个 tick 只触发一次 → 参见 reactivity-same-tick-batching
计算属性
- 计算属性的 getter 意外触发突变或请求 → 参见 computed-no-side-effects
- 修改计算属性值导致更改消失 → 参见 computed-return-value-readonly
- 计算属性在条件逻辑后从不更新 → 参见 computed-conditional-dependencies
- 对数组进行排序或反转破坏了原始状态 → 参见 computed-array-mutation
- 向计算属性传递参数失败 → 参见 computed-no-parameters
观察者
- 异步操作被过时数据覆盖 → 参见 watch-async-cleanup
- 在异步回调中创建观察者 → 参见 watch-async-creation-memory-leak
- 观察者从未触发响应式对象属性 → 参见 watch-reactive-property-getter
- 异步 watchEffect 在 await 后遗漏依赖 → 参见 watcheffect-async-dependency-tracking
- 观察者回调中的 DOM 读取是过时的 → 参见 watch-flush-timing
- 深度观察者报告相同的旧/新值 → 参见 watch-deep-same-object-reference
- watchEffect 在模板 ref 更新之前运行 → 参见 watcheffect-flush-post-for-refs
组件
- 子组件抛出“组件未找到”错误 → 参见 local-components-not-in-descendants
- 点击监听器在自定义组件上不触发 → 参见 click-events-on-components
- 父组件无法访问 script setup 中的子组件 ref 数据 → 参见 component-ref-requires-defineexpose
- HTML 模板解析破坏 Vue 组件语法 → 参见 in-dom-template-parsing-caveats
- 由于命名冲突渲染了错误的组件 → 参见 component-naming-conflicts
- 父组件样式不应用于多根组件 → 参见 multi-root-component-class-attrs
Props 与 Emits
- defineProps 中引用的变量导致错误 → 参见 prop-defineprops-scope-limitation
- 组件发出未声明的事件导致警告 → 参见 declare-emits-for-documentation
- defineEmits 在函数或条件中使用 → 参见 defineEmits-must-be-top-level
- defineEmits 同时具有类型和运行时参数 → 参见 defineEmits-no-runtime-and-type-mixed
- 原生事件监听器未响应点击 → 参见 native-event-collision-with-emits
- 点击时组件事件触发两次 → 参见 undeclared-emits-double-firing
模板
- 使用语句时出现模板编译错误 → 参见 template-expressions-restrictions
- “无法读取未定义的属性”运行时错误 → 参见 v-if-null-check-order
- 动态指令参数无法正常工作 → 参见 dynamic-argument-constraints
- v-else 元素始终无条件渲染 → 参见 v-else-must-follow-v-if
- 混合 v-if 与 v-for 导致优先级错误和迁移问题 → 参见 no-v-if-with-v-for
- 模板函数调用修改状态导致不可预测的重新渲染错误 → 参见 template-functions-no-side-effects
- 循环中的子组件显示未定义数据 → 参见 v-for-component-props
- 排序或反转后数组顺序改变 → 参见 v-for-computed-reverse-sort
- 列表项意外消失或状态交换 → 参见 v-for-key-attribute
- 范围迭代出现差一错误 → 参见 v-for-range-starts-at-one
- v-show 或 v-else 在 template 元素上不起作用 → 参见 v-show-template-limitation
模板引用
- 元素条件隐藏时 ref 变为 null → 参见 template-ref-null-with-v-if
- 循环中 ref 数组索引与数据数组不匹配 → 参见 template-ref-v-for-order
- 重构模板 ref 名称在代码中静默失败 → 参见 use-template-ref-vue35
表单与 v-model
- 使用 v-model 时初始表单值不显示 → 参见 v-model-ignores-html-attributes
- 文本区域内容更改未更新 ref → 参见 textarea-no-interpolation
- iOS 用户无法选择下拉列表的第一个选项 → 参见 select-initial-value-ios-bug
- 父组件和子组件具有不同的值 → 参见 define-model-default-value-sync
- 对象属性更改未同步到父组件 → 参见 definemodel-object-mutation-no-emit
- 中文/日文输入时实时搜索/验证失效 → 参见 v-model-ime-composition
- 数字输入返回空字符串而不是零 → 参见 v-model-number-modifier-behavior
- 自定义复选框值未在表单中提交 → 参见 checkbox-true-false-value-form-submission
事件与修饰符
- 链式多个事件修饰符产生意外结果 → 参见 event-modifier-order-matters
- 键盘快捷键在系统修饰键下不触发 → 参见 keyup-modifier-timing
- 键盘快捷键触发意外的修饰符组合 → 参见 exact-modifier-for-precise-shortcuts
- 组合 passive 和 prevent 修饰符破坏事件行为 → 参见 no-passive-with-prevent
生命周期
- 未移除的事件监听器导致内存泄漏 → 参见 cleanup-side-effects
- 组件挂载前 DOM 访问失败 → 参见 lifecycle-dom-access-timing
- 状态更改后 DOM 读取返回过时值 → 参见 dom-update-timing-nexttick
- SSR 渲染与客户端水合不同 → 参见 lifecycle-ssr-awareness
- 异步注册的生命周期钩子从不运行 → 参见 lifecycle-hooks-synchronous-registration
插槽
- 在插槽内容中访问子组件数据返回未定义值 → 参见 slot-render-scope-parent-only
- 混合具名插槽和作用域插槽导致编译错误 → 参见 slot-named-scoped-explicit-default
- 在原生 HTML 元素上使用 v-slot 导致编译错误 → 参见 slot-v-slot-on-components-or-templates-only
- 隐式默认插槽行为导致意外内容放置 → 参见 slot-implicit-default-content
- 作用域插槽 props 缺少预期的 name 属性 → 参见 slot-name-reserved-prop
- 包装组件破坏子插槽功能 → 参见 slot-forwarding-to-child-components
Provide/Inject
- 异步操作后调用 provide 静默失败 → 参见 provide-inject-synchronous-setup
- 追踪提供值的来源 → 参见 provide-inject-debugging-challenges
- 提供者更改时注入的值不更新 → 参见 provide-inject-reactivity-not-automatic
- 多个组件共享同一个默认对象 → 参见 provide-inject-default-value-factory
Attrs
- 内部和透传事件处理程序都执行 → 参见 attrs-event-listener-merging
- 显式属性被透传值覆盖 → 参见 fallthrough-attrs-overwrite-vue3
- 属性应用于包装器中的错误元素 → 参见 inheritattrs-false-for-wrapper-components
组合式函数
- 在 setup 上下文之外或异步调用组合式函数 → 参见 composable-call-location-restrictions
- 组合式函数的响应式依赖在输入更改时不更新 → 参见 composable-tovalue-inside-watcheffect
- 组合式函数意外修改外部状态 → 参见 composable-avoid-hidden-side-effects
- 解构组合式函数返回值意外破坏响应性 → 参见 composable-naming-return-pattern
组合式 API
- 异步操作后生命周期钩子静默失败 → 参见 composition-api-script-setup-async-context
- 父组件 ref 无法访问暴露的属性 → 参见 define-expose-before-await
- 函数式编程模式破坏预期的 Vue 响应式行为 → 参见 composition-api-not-functional-programming
- React Hook 心智模型导致组合式 API 使用错误 → 参见 composition-api-vs-react-hooks-differences
动画
- DOM 节点被重用时动画无法触发 → 参见 animation-key-for-rerender
- TransitionGroup 列表更新在负载下感觉卡顿 → 参见 animation-transitiongroup-performance
TypeScript
- 可变的 prop 默认值在组件实例之间泄漏状态 → 参见 ts-withdefaults-mutable-factory-function
- reactive() 泛型类型导致 ref 解包不匹配 → 参见 ts-reactive-no-generic-argument
- 模板 ref 在挂载前或 v-if 卸载后抛出 null 访问错误 → 参见 ts-template-ref-null-handling
- 可选的布尔 prop 表现为 false 而不是 undefined → 参见 ts-defineprops-boolean-default-false
- 导入的 defineProps 类型因无法解析或复杂类型引用而失败 → 参见 ts-defineprops-imported-types-limitations
- 未类型化的 DOM 事件处理程序在严格 TypeScript 设置下失败 → 参见 ts-event-handler-explicit-typing
- 动态组件 ref 触发响应式组件警告 → 参见 ts-shallowref-for-dynamic-components
- 联合类型的模板表达式在没有窄化的情况下类型检查失败 → 参见 ts-template-type-casting
异步组件
- 路由组件使用 defineAsyncComponent 懒加载配置错误 → 参见 async-component-vue-router
- 加载组件时网络故障或超时 → 参见 async-component-error-handling
- 组件重新激活后模板 ref 未定义 → 参见 async-component-keepalive-ref-issue
渲染函数
- 状态更改后渲染函数输出保持静态 → 参见 rendering-render-function-return-from-setup
- 重复使用的 vnode 实例渲染不正确 → 参见 render-function-vnodes-must-be-unique
- 字符串组件名称渲染为 HTML 元素 → 参见 rendering-resolve-component-for-string-names
- 访问 vnode 内部属性在 Vue 更新时失效 → 参见 render-function-avoid-internal-vnode-properties
- Vue 2 渲染函数模式在 Vue 3 中崩溃 → 参见 rendering-render-function-h-import-vue3
- 插槽内容未从 h() 渲染 → 参见 rendering-render-function-slots-as-functions
KeepAlive
- 子组件在嵌套 Vue Router 路由中挂载两次 → 参见 keepalive-router-nested-double-mount
- 将 KeepAlive 与 Transition 动画结合时内存增长 → 参见 keepalive-transition-memory-leak
过渡
- JavaScript 过渡钩子在缺少 done 回调时挂起 → 参见 transition-js-hooks-done-callback
- 内联列表元素上的移动动画失败 → 参见 transition-group-flip-inline-elements
- 列表项跳跃而不是平滑动画 → 参见 transition-group-move-animation-position-absolute
- Vue 2 到 Vue 3 TransitionGroup 包装器更改破坏布局 → 参见 transition-group-no-default-wrapper-vue3
- 嵌套过渡在完成前被截断 → 参见 transition-nested-duration
- 作用域样式在可复用的过渡包装器中失效 → 参见 transition-reusable-scoped-style
- RouterView 过渡在首次渲染时意外动画 → 参见 transition-router-view-appear
- 混合 CSS 过渡和动画导致时间问题 → 参见 transition-type-when-mixed
- 快速过渡切换期间错过清理钩子 → 参见 transition-unmount-hook-timing
Teleport
- Teleport 目标元素在 DOM 中未找到 → 参见 teleport-target-must-exist
- Teleport 内容破坏 SSR 水合 → 参见 teleport-ssr-hydration
- 作用域样式不应用于 teleport 内容 → 参见 teleport-scoped-styles-limitation
Suspense
- 需要处理来自 Suspense 组件的异步错误 → 参见 suspense-no-builtin-error-handling
- 在服务器端渲染中使用 Suspense → 参见 suspense-ssr-hydration-issues
- 异步组件加载/错误 UI 在 Suspense 下被忽略 → 参见 async-component-suspense-control
SSR
- 服务器和客户端渲染的 HTML 不同 → 参见 ssr-hydration-mismatch-causes
- 共享单例存储导致用户状态在请求之间泄漏 → 参见 state-ssr-cross-request-pollution
- 仅浏览器 API 在通用代码路径中导致服务器渲染崩溃 → 参见 ssr-platform-specific-apis
性能
- 列表子组件因父组件传递不稳定 props 而不必要地重新渲染 → 参见 perf-props-stability-update-optimization
- 计算对象尽管值相等仍重新触发副作用 → 参见 perf-computed-object-stability
SFC(单文件组件)
- 尝试从组件脚本块使用命名导出 → 参见 sfc-named-exports-forbidden
- 更改后模板中的变量不更新 → 参见 sfc-script-setup-reactivity
- 作用域样式不应用于子组件元素 → 参见 sfc-scoped-css-child-component-styling
- 作用域样式不应用于动态 v-html 内容 → 参见 sfc-scoped-css-dynamic-content
- 作用域样式不应用于插槽内容 → 参见 sfc-scoped-css-slot-content
- 动态构建时 Tailwind 类缺失 → 参见 tailwind-dynamic-class-generation
- 递归组件因名称冲突无法渲染 → 参见 self-referencing-component-name
插件
- 调试全局属性导致命名冲突 → 参见 plugin-global-properties-sparingly
- 插件不工作或 inject 返回 undefined → 参见 plugin-install-before-mount
- 插件全局属性在基于 setup 的组件中不可用 → 参见 plugin-prefer-provide-inject-over-global-properties
- 插件类型增强错误破坏 ComponentCustomProperties 类型 → 参见 plugin-typescript-type-augmentation
应用配置
- 挂载调用后应用配置方法不工作 → 参见 configure-app-before-mount
- 从 mount() 链式调用应用配置失败,因为 mount 返回组件实例 → 参见 mount-return-value
- 基于 require.context 的组件自动注册在 Vite 中失败 → 参见 dynamic-component-registration-vite






