components
БесплатноБез исполняемых скриптовНе проверенTeaches Vue component fundamentals including markup, logic, and styles. Use when building or structuring Vue single-file components as the foundational…
от PatternsDev★ 261 звезда на GitHubОб этом скилле
Components
Table of Contents
Vue components are the building blocks of Vue apps by allowing us to couple markup (HTML), logic (JS), and styles (CSS) within them.
When working within a Vue application, it's important to understand that almost every element displayed in the UI is oftentimes part of a Vue component. This is because a Vue application is often composed of components nested within components, forming a hierarchical structure.
When to Use
- Use this as foundational knowledge for building any Vue application
- This is helpful for understanding how to structure, compose, and reuse UI elements in Vue
Instructions
- Use single-file components (
.vuefiles) with<template>,<script setup>, and<style>sections - Extract reusable parts of large components into smaller child components
- Use
ref()for reactive primitive values andreactive()for reactive objects - Pass data from parent to child using props; emit events from child to parent
Details
Reusability and maintainability are some of the main reasons why building an application with well-structured components are especially important.
To get a better understanding of components, we'll go ahead and create one. The simplest way to create a Vue component in an application that doesn't contain a build process (e.g. Webpack) is to create a plain JavaScript object that contains Vue specific options.
export default {
props: ["name"],
template: `<h1>Hello, my name is {{ name }}</h1>`,
};
The component has a props property defined, which accepts a single prop named name. Props are a way to pass data into a component from its parent component.
The template property defines the HTML template for the component. In this case, it contains an <h1> heading tag that displays the text "Hello, my name is" followed by the value of the name prop, which is rendered using Vue's double curly braces syntax {{ }}.
Aside from defining components as plain JavaScript objects, the most common way of creating components in Vue are with single-file components (SFCs). Single-file components are components that allow us to define the HTML, CSS, and JS of a component all within a special .vue file, as shown below:
<template>
<h1>Hello, my name is {{ name }}</h1>
</template>
<script setup>
const { name } = defineProps(["name"]);
</script>
Note: Single-file components in Vue are made possible due to build tools like Vite. These tools help compile
.vuecomponents to plain JavaScript modules that can be understood in browsers.
Components = building blocks
We'll go through a simple exercise to illustrate how components can be split into smaller components. Consider a fictional Tweet component.
The component can be implemented with something as follows:
<template>
<div class="Tweet">
<image class="Tweet-image" :src="image.imageUrl" :alt="image.description" />
<div class="User">
<image class="Avatar" :src="author.avatarUrl" :alt="author.name" />
<div class="User-name">{{ author.name }}</div>
</div>
<div class="Details">
<div class="Tweet-text">{{ text }}</div>
<div class="Tweet-date">{{ formatDate(date) }}</div>
<!-- ... -->
</div>
</div>
</template>
<script setup>
// ...
</script>
One can look at the above component and consider it difficult to manipulate because of how clustered it is, and reusing individual parts of it may also prove difficult. To make things more composable, we can extract a few components from this one component.
We can have the main Tweet component be the parent to the TweetUser and TweetDetails components. TweetUser will display the user's information and be a parent to a TweetAvatar component that displays the user's avatar. TweetDetails will simply display additional information in the tweet such as the tweet text and the date of submission.
We can first create the child TweetAvatar component to contain the avatar image element.
<template>
<image class="Avatar" :src="author.avatarUrl" :alt="author.name" />
</template>
<script setup>
// ...
</script>
We can then create the TweetUser component that renders the TweetAvatar component and relevant user information.
<template>
<div class="User">
<TweetAvatar />
<div class="User-name">{{ author.name }}</div>
</div>
</template>
<script setup>
import { TweetAvatar } from "./TweetAvatar.vue";
</script>
We can create the TweetDetails component to render the remaining information in the tweet.
<template>
<div class="Details">
<div class="Tweet-text">{{ text }}</div>
<div class="Tweet-date">{{ formatDate(date) }}</div>
<!-- ... -->
</div>
</template>
<script setup>
// ...
</script>
Finally, we can use these newly created child com
Установить components в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл components?
Teaches Vue component fundamentals including markup, logic, and styles. Use when building or structuring Vue single-file components as the foundational building blocks of your application.
Как установить скилл components?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл components запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic