All skills
hyf0 avatar

/vue-debug-guides

@a5fc891 official
by hyf0hyf0/vue-skills2.9k stars
167

Vue 3 debugging and error handling for runtime errors, warnings, async failures, and SSR/hydration issues. Use when diagnosing or fixing Vue issues.

Use this Skill: https://skilld.dev/gh/hyf0/vue-skills/vue-debug-guides

This session only. Nothing lands on disk.

referencev-else-must-follow-v-if.md

≈991 tokens on demand. Your agent reads this file only when SKILL.md points to it.

v-else Must Immediately Follow v-if or v-else-if

Impact: MEDIUM - A v-else or v-else-if element must immediately follow a v-if or v-else-if element in the DOM. If there's any element in between:

  • SFC compilation (Vite/vue-loader): Vue throws a compile-time SyntaxError - the code won't build at all
  • Runtime template compilation: The element renders unconditionally (always visible), losing its conditional behavior

In most modern Vue projects using Single File Components, this is caught at build time.

Task Checklist

  • Place v-else immediately after the v-if element (no elements in between)
  • Place v-else-if immediately after v-if or another v-else-if
  • Use <template> wrapper if you need to group multiple elements within a branch
  • If you need content between conditions, restructure using nested conditionals or computed

Incorrect:

<!-- WRONG: v-else not immediately after v-if -->
<template>
  <div v-if="isLoggedIn">
    Welcome back!
  </div>

  <p>Some other content in between</p>

  <div v-else>
    <!-- This v-else is NOT recognized! It will ALWAYS render (unconditionally) -->
    Please log in
  </div>
</template>
<!-- WRONG: Comment or whitespace element between -->
<template>
  <span v-if="status === 'loading'">Loading...</span>
  <!-- This comment breaks the chain! -->
  <span v-else-if="status === 'error'">Error occurred</span>
  <span v-else>Done</span>
</template>
<!-- WRONG: Text node between conditions -->
<template>
  <div v-if="showA">A</div>
  Just some text here
  <div v-else>B</div>  <!-- Not recognized, always renders -->
</template>

Correct:

<!-- CORRECT: v-else immediately follows v-if -->
<template>
  <div v-if="isLoggedIn">
    Welcome back!
  </div>
  <div v-else>
    Please log in
  </div>

  <p>Some other content (placed after the conditional block)</p>
</template>
<!-- CORRECT: Full v-if/v-else-if/v-else chain -->
<template>
  <span v-if="status === 'loading'">Loading...</span>
  <span v-else-if="status === 'error'">Error: {{ errorMessage }}</span>
  <span v-else-if="status === 'empty'">No data found</span>
  <span v-else>{{ data }}</span>
</template>
<!-- CORRECT: Using <template> for multiple elements per branch -->
<template>
  <template v-if="isLoggedIn">
    <h1>Welcome back!</h1>
    <p>Your dashboard</p>
    <UserStats />
  </template>
  <template v-else>
    <h1>Please log in</h1>
    <LoginForm />
  </template>
</template>
<!-- CORRECT: Restructure if you need content between conditions -->
<template>
  <div class="conditional-section">
    <div v-if="isLoggedIn">Welcome back!</div>
    <div v-else>Please log in</div>
  </div>

  <div class="always-shown">
    Some other content
  </div>

  <div class="another-conditional">
    <div v-if="showMore">More info</div>
    <div v-else>Click to expand</div>
  </div>
</template>

Debugging Tips

<!-- If v-else is always visible (rendering unconditionally), check for: -->

<!-- 1. Elements between v-if and v-else -->
<!-- 2. HTML comments that break the chain -->
<!-- 3. Text nodes (including whitespace in some cases) -->
<!-- 4. Component tags that render content between -->

<!-- SFC compilation throws: "v-else/v-else-if has no adjacent v-if or v-else-if" (build fails) -->
<!-- Runtime template compilation shows a warning but renders the element unconditionally -->
<!-- Vue DevTools will show the v-else element as not part of the condition chain -->

Reference

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill is a comprehensive collection of educational debugging guides and best practices for Vue 3 developers. It contains no executable code or malicious instructions and focuses solely on diagnosing common runtime errors and performance issues.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    140 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at a5fc891. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 8 months ago

README badge

README badge for hyf0/vue-skills/vue-debug-guides

Guides for diagnosing and fixing Vue 3 runtime errors, reactivity bugs, async failures, and hydration issues across components, templates, watchers, forms, and lifecycle hooks. Covers specific failure modes like stale watchers, ref unwrapping edge cases, v-model sync problems, and SSR mismatches with concrete reference links for each issue.

Generated from the current SKILL.md.

Does this skill cover Vue 2?
No. This skill is specific to Vue 3 debugging and error handling.
What should I use for Vue development best practices instead of debugging?
The skill references a separate `vue-best-practices` skill for development best practices and common gotchas.
Does this cover SSR and hydration issues?
Yes. The skill includes guides for diagnosing and fixing SSR rendering differences and hydration bugs.
Can this help with async watcher and watchEffect problems?
Yes. The skill covers async operation stale data, dependency tracking after await, and proper flush timing for watchers.
Does this address v-model and form-related issues?
Yes. The skill includes guides for v-model initial values, textarea interpolation, IME composition, and custom checkbox form submission.

Generated from the current SKILL.md. These answers refresh after source changes.