All skills
vuejs-ai avatar

/vue-debug-guides

@a5fc891 official
by Vue AIvuejs-ai/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/vuejs-ai/skills/vue-debug-guides

This session only. Nothing lands on disk.

referenceteleport-scoped-styles-limitation.md

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

Scoped Styles May Not Apply to Teleported Content

Impact: MEDIUM - When using scoped styles with Teleport, the styles may not apply correctly to teleported elements. This is a known limitation related to how Vue's scoped style attributes work with elements rendered outside the component's DOM tree.

Task Checklist

  • Test scoped styles on teleported content
  • Use :deep() selector or non-scoped styles for teleported content
  • Consider CSS modules as an alternative
  • Keep teleported content styles in a separate non-scoped style block

Problem - Scoped Styles Not Applied:

<template>
  <Teleport to="body">
    <div class="modal">
      <p class="modal-text">This text may not be styled!</p>
    </div>
  </Teleport>
</template>

<style scoped>
/* These styles may NOT apply to teleported content */
.modal {
  background: white;
  padding: 20px;
}

.modal-text {
  color: blue;  /* May not work */
}
</style>

Solution 1 - Use Non-Scoped Styles for Teleported Content:

<template>
  <Teleport to="body">
    <div class="my-modal">
      <p class="my-modal-text">This text will be styled</p>
    </div>
  </Teleport>
</template>

<style scoped>
/* Component-specific styles */
.button { color: blue; }
</style>

<style>
/* Non-scoped styles for teleported content */
/* Use specific class names to avoid conflicts */
.my-modal {
  background: white;
  padding: 20px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.my-modal-text {
  color: blue;
}
</style>

Solution 2 - Use :deep() Selector:

<template>
  <Teleport to="body">
    <div class="modal">
      <p class="modal-text">Styled with :deep()</p>
    </div>
  </Teleport>
</template>

<style scoped>
:deep(.modal) {
  background: white;
  padding: 20px;
}

:deep(.modal-text) {
  color: blue;
}
</style>

Solution 3 - CSS Modules:

<template>
  <Teleport to="body">
    <div :class="$style.modal">
      <p :class="$style.modalText">Styled with CSS modules</p>
    </div>
  </Teleport>
</template>

<style module>
.modal {
  background: white;
  padding: 20px;
}

.modalText {
  color: blue;
}
</style>

Multi-Root Components with Teleport

Using Teleport as one of multiple root nodes causes additional issues:

<template>
  <!-- Multi-root component -->
  <button @click="open = true">Open</button>
  <Teleport to="body">
    <div class="modal">Content</div>
  </Teleport>
</template>

<!-- Warning: class/style attributes may not be inherited -->

Pass classes explicitly to avoid inheritance issues:

<template>
  <button @click="open = true">Open</button>
  <Teleport to="body">
    <div :class="['modal', $attrs.class]" :style="$attrs.style">
      Content
    </div>
  </Teleport>
</template>

Best Practice: Dedicated Modal Styles

Create a dedicated stylesheet for modal/overlay components:

/* modal-styles.css */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
}
<script setup>
import './modal-styles.css'
</script>

<template>
  <Teleport to="body">
    <div v-if="open" class="modal-overlay">
      <div class="modal-content">
        <slot />
      </div>
    </div>
  </Teleport>
</template>

Reference

Source: SKILL.md on GitHub

1 warning17d5 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/140 files flagged

  • 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 vuejs-ai/skills/vue-debug-guides

Guides for diagnosing Vue 3 runtime errors, reactivity bugs, component lifecycle issues, and SSR hydration problems. Covers reactivity traps (refs, computed, watchers), component mechanics (props, emits, slots), templates (v-if, v-for, refs), forms (v-model), and composition API gotchas.

Generated from the current SKILL.md.

Does this cover Vue 2 or only Vue 3?
This skill is for Vue 3 only. It addresses Vue 3-specific debugging patterns like reactivity proxies, script setup, and defineEmits/defineProps.
Does this skill help with performance optimization?
No. This skill focuses on runtime errors, warnings, and behavioral bugs. For development best practices and optimization, use the separate `vue-best-practices` skill.
What kinds of issues does this cover?
Reactivity traps (refs, computed, watchers), component lifecycle bugs, template directives, form binding edge cases, SSR/hydration mismatches, slot scoping, and async-related failures.
Does this include debugging for Nuxt or other Vue frameworks?
No. This skill focuses on core Vue 3 runtime issues. Framework-specific bugs are outside its scope.

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