vue

Guide Vue 3 Composition API and script setup for TypeScript Single File Components.

2|Updated Oct 5, 2024
One-click install
npx skills add https://github.com/remoodle/heresy --skill vue-remoodle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue
Source: https://github.com/remoodle/heresy/tree/main/src/calendar/.agents/skills/vue
Command: npx skills add https://github.com/remoodle/heresy --skill vue-remoodle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers efficiently build modern Vue.js applications by leveraging the Composition API, script setup, and advanced features for better performance and maintainability.

Core Features & Use Cases

  • Composition API & Script Setup: Write cleaner, more organized Vue components using <script setup lang="ts">.
  • Reactivity System: Understand and utilize ref, shallowRef, computed, and watch for dynamic UIs.
  • Built-in Components: Master Transition, Teleport, Suspense, and KeepAlive for enhanced user experiences.
  • Use Case: When developing a new Vue 3 component, use this Skill to quickly recall the correct syntax for defining props, handling emits, and managing component lifecycle hooks.

Quick Start

Use the vue skill to generate a basic Vue 3 component using <script setup lang="ts"> with a reactive counter.

Frequently Asked Questions about vue

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define props and emits in Vue 3 script setup with TypeScript?

In Vue 3 script setup with TypeScript, you define props and emits using the defineProps and defineEmits compiler macros. This enables type-safe component interfaces for performant Single File Components.

What is the difference between ref and shallowRef in Vue 3 reactivity?

Vue 3 reactivity uses ref to deeply track changes in reactive objects, while shallowRef only tracks replacement of the entire value. Use shallowRef to optimize performance when deep reactivity is unnecessary.

How do I use Teleport and Suspense built-in components in Vue 3?

Vue 3 built-in components like Teleport and Suspense manage sophisticated UI rendering. Teleport renders content at a different DOM location, while Suspense handles asynchronous component loading states.

Can I manage Vue 3 component lifecycle hooks inside script setup?

Yes, you manage Vue 3 component lifecycle hooks inside script setup by importing functions like onMounted and onUnmounted. This organizes hook logic directly within the Composition API scope.

When should I use KeepAlive and Transition for Vue 3 dynamic components?

Use KeepAlive to cache dynamic Vue 3 component states and prevent re-rendering. Combine it with Transition to apply animation effects during component switching for an enhanced user experience.

What's the best way to write computed properties and watchers in Vue 3?

The best way to write computed properties and watchers in Vue 3 is using the computed and watch functions. This approach derives reactive state and executes side effects cleanly within script setup.