Vue 3 應用程式會遇到難以偵錯的執行階段錯誤、警告訊息、非同步失敗和 SSR 水合問題。本技能提供全面的偵錯指南和超過 100 個常見 Vue 3 開發問題的解決方案。
스킬 ZIP 다운로드
Claude에서 업로드
설정 → 기능 → 스킬 → 스킬 업로드로 이동
토글을 켜고 사용 시작
테스트해 보기
"vue-debug-guides" 사용 중입니다. 為什麼我的 computed 屬性沒有更新?
예상 결과:
這可能是 computed 屬性依賴問題。Vue 3 中的 computed 屬性只會追蹤其 getter 函式中存取的響應式依賴。如果您正在解構 reactive 物件或在條件後存取巢狀屬性,computed 可能不會更新。請參閱「computed-conditional-dependencies」指南以取得解決方案。
"vue-debug-guides" 사용 중입니다. 如何在 Vue SSR 中修復水合不相符?
예상 결과:
當伺服器和客戶端呈現不同內容時會發生水合不相符。常見原因包括:1) 使用瀏覽器專用 API 如 localStorage 或 window,2) 渲染期間產生的隨機值,3) CSS 導致的佈局差異。對瀏覽器 API 使用 onMounted,對隨機值進行 seeding,並對動態內容使用 ClientOnly 元件。
"vue-debug-guides" 사용 중입니다. 為什麼我的模板 refs 是 undefined?
예상 결과:
模板 refs 只在元件 mount 後才能存取。如果您在 setup() 中嘗試存取它們,它們將是 undefined。請使用 onMounted 生命週期鉤子或 flush: 'post' 的 watchEffect 以確保 refs 已填入。另請檢查元素是否使用 v-if 條件渲染 - v-if 元素的 refs 在條件為 false 時會是 null。
보안 감사
안전This skill contains Vue.js debugging guides as markdown documentation. Static analysis flagged patterns in code examples within documentation. All findings are FALSE POSITIVES - backticks are markdown code formatting, URLs are documentation examples, and code snippets showing problematic patterns are educational content, not vulnerabilities. Safe for publication.
품질 점수
만들 수 있는 것
偵錯響應式問題
當 Vue 元件因響應式參考問題、解構錯誤或 computed 屬性問題而意外停止更新時
修復 SSR 水合錯誤
當伺服器端渲染的 Vue 應用程式顯示水合不相符警告或客戶端-伺服器內容差異時
解決非同步元件失敗
當延遲載入的元件載入失敗、顯示錯誤不正確或導致 Vue 應用程式記憶體洩漏時
이 프롬프트를 사용해 보세요
我的 Vue 3 元件在變更資料時沒有更新。ref 值有變化但模板沒有重新渲染。我該如何偵錯這個問題?
我的 Nuxt 應用程式出現水合不相符警告。伺服器 HTML 與客戶端不一致。我該如何解決?
我的監聽器在 reactive 物件中的巢狀屬性變更時未觸發。我使用了 deep: true,但回調函式從未帶有新舊值觸發。
我在非同步元件中使用 KeepAlive,我的應用程式顯示記憶體洩漏。mounted 鉤子多次執行但 unmounted 從未觸發。我該如何解決?
모범 사례
- 使用 Vue DevTools 即時檢查元件狀態、props 和發出的事件
- 在開發期間啟用 Vue 的嚴格模式以儘早發現響應式問題
- 始終明確宣告 emits 以避免意外重複觸發事件
피하기
- 直接解構 reactive 物件 - 這會破壞響應式,必須使用 toRefs 或 toRaw
- 使用 v-for 時不指定 :key - 會導致渲染問題和不可預測的行為
- 僅在執行時定義 emits 而不進行類型基礎的宣告 - 會失去類型安全
자주 묻는 질문
本技能是否適用於 Vue 2?
本技能能否幫助解決效能問題?
這是否涵蓋 Nuxt 特定問題?
如何偵錯響應式狀態未更新的問題?
這能否幫助解決 Vue 中的 TypeScript 錯誤?
如何偵錯非同步元件載入失敗?
개발자 세부 정보
파일 구조
📄 animation-key-for-rerender.md
📄 animation-transitiongroup-performance.md
📄 async-component-error-handling.md
📄 async-component-keepalive-ref-issue.md
📄 async-component-suspense-control.md
📄 async-component-vue-router.md
📄 attrs-event-listener-merging.md
📄 checkbox-true-false-value-form-submission.md
📄 click-events-on-components.md
📄 component-naming-conflicts.md
📄 component-ref-requires-defineexpose.md
📄 composable-avoid-hidden-side-effects.md
📄 composable-call-location-restrictions.md
📄 composable-naming-return-pattern.md
📄 composable-tovalue-inside-watcheffect.md
📄 composition-api-not-functional-programming.md
📄 composition-api-script-setup-async-context.md
📄 composition-api-vs-react-hooks-differences.md
📄 computed-conditional-dependencies.md
📄 computed-return-value-readonly.md
📄 configure-app-before-mount.md
📄 declare-emits-for-documentation.md
📄 define-expose-before-await.md
📄 define-model-default-value-sync.md
📄 defineEmits-must-be-top-level.md
📄 defineEmits-no-runtime-and-type-mixed.md
📄 definemodel-object-mutation-no-emit.md
📄 dom-update-timing-nexttick.md
📄 dynamic-argument-constraints.md
📄 dynamic-component-registration-vite.md
📄 event-modifier-order-matters.md
📄 exact-modifier-for-precise-shortcuts.md
📄 fallthrough-attrs-overwrite-vue3.md
📄 in-dom-template-parsing-caveats.md
📄 inheritattrs-false-for-wrapper-components.md
📄 keepalive-router-nested-double-mount.md
📄 keepalive-transition-memory-leak.md
📄 lifecycle-dom-access-timing.md
📄 lifecycle-hooks-synchronous-registration.md
📄 local-components-not-in-descendants.md
📄 multi-root-component-class-attrs.md
📄 native-event-collision-with-emits.md
📄 perf-computed-object-stability.md
📄 perf-props-stability-update-optimization.md
📄 plugin-global-properties-sparingly.md
📄 plugin-install-before-mount.md
📄 plugin-prefer-provide-inject-over-global-properties.md
📄 plugin-typescript-type-augmentation.md
📄 prop-defineprops-scope-limitation.md
📄 provide-inject-debugging-challenges.md
📄 provide-inject-default-value-factory.md
📄 provide-inject-reactivity-not-automatic.md
📄 provide-inject-synchronous-setup.md
📄 reactivity-debugging-hooks.md
📄 reactivity-markraw-for-non-reactive.md
📄 reactivity-proxy-identity-hazard.md
📄 reactivity-same-tick-batching.md
📄 refs-in-collections-need-value.md
📄 render-function-avoid-internal-vnode-properties.md
📄 render-function-vnodes-must-be-unique.md
📄 rendering-render-function-h-import-vue3.md
📄 rendering-render-function-return-from-setup.md
📄 rendering-render-function-slots-as-functions.md
📄 rendering-resolve-component-for-string-names.md
📄 select-initial-value-ios-bug.md
📄 self-referencing-component-name.md
📄 sfc-named-exports-forbidden.md
📄 sfc-scoped-css-child-component-styling.md
📄 sfc-scoped-css-dynamic-content.md
📄 sfc-scoped-css-slot-content.md
📄 sfc-script-setup-reactivity.md
📄 slot-forwarding-to-child-components.md
📄 slot-implicit-default-content.md
📄 slot-named-scoped-explicit-default.md
📄 slot-render-scope-parent-only.md
📄 slot-v-slot-on-components-or-templates-only.md
📄 ssr-hydration-mismatch-causes.md
📄 ssr-platform-specific-apis.md
📄 state-ssr-cross-request-pollution.md
📄 suspense-no-builtin-error-handling.md
📄 suspense-ssr-hydration-issues.md
📄 tailwind-dynamic-class-generation.md
📄 teleport-scoped-styles-limitation.md
📄 teleport-target-must-exist.md
📄 template-expressions-restrictions.md
📄 template-functions-no-side-effects.md
📄 template-ref-null-with-v-if.md
📄 template-ref-unwrapping-top-level.md
📄 textarea-no-interpolation.md
📄 transition-group-flip-inline-elements.md
📄 transition-group-move-animation-position-absolute.md
📄 transition-group-no-default-wrapper-vue3.md
📄 transition-js-hooks-done-callback.md
📄 transition-nested-duration.md
📄 transition-reusable-scoped-style.md
📄 transition-router-view-appear.md
📄 transition-type-when-mixed.md
📄 transition-unmount-hook-timing.md
📄 ts-defineprops-boolean-default-false.md
📄 ts-defineprops-imported-types-limitations.md
📄 ts-event-handler-explicit-typing.md
📄 ts-reactive-no-generic-argument.md
📄 ts-shallowref-for-dynamic-components.md
📄 ts-template-ref-null-handling.md
📄 ts-withdefaults-mutable-factory-function.md
📄 undeclared-emits-double-firing.md
📄 v-for-computed-reverse-sort.md
📄 v-for-range-starts-at-one.md
📄 v-model-ignores-html-attributes.md
📄 v-model-number-modifier-behavior.md
📄 v-show-template-limitation.md
📄 watch-async-creation-memory-leak.md
📄 watch-deep-same-object-reference.md
📄 watch-reactive-property-getter.md
📄 watcheffect-async-dependency-tracking.md
📄 watcheffect-flush-post-for-refs.md
📄 SKILL.md