Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)6.0k · #14448

vue

Skill này làm gì

Skill này giải thích cách xây dựng giao diện người dùng bằng Vue 3, dùng Composition API hiện đại và TypeScript. Skill dành cho lập trình viên làm trang web hoặc ứng dụng với Vue.

Khi nào nên dùng

  • ✓Khi bạn đang viết hoặc chỉnh sửa một single-file component của Vue.
  • ✓Khi bạn cần định nghĩa props, emits hoặc model hai chiều cho component.
  • ✓Khi bạn muốn dùng transition, watcher hoặc các component có sẵn như Teleport.

Liên kết skill

https://github.com/antfu/skills/blob/main/skills/vue/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/antfu/skills/blob/main/skills/vue/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Xây dựng một component Vue cho ô tìm kiếm, phát ra văn bản đang gõ và hiển thị nút xóa.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent làm theo phong cách Composition API của Vue 3 với script setup và TypeScript, dùng các công cụ phản ứng hiện tại và cách xử lý dữ liệu đơn giản, hiệu quả.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Vue

Based on Vue 3.5, generated at 2026-09-25. Always use Composition API with <script setup lang="ts">.

Preferences

  • Prefer TypeScript over JavaScript
  • Prefer <script setup lang="ts"> over <script>
  • For performance, prefer shallowRef over ref if deep reactivity is not needed
  • Always use Composition API over Options API
  • Discourage using Reactive Props Destructure

Core

Topic Description Reference
Script Setup & Macros <script setup>, defineProps, defineEmits, defineModel, defineExpose, defineOptions, defineSlots, generics script-setup-macros
Reactivity & Lifecycle ref, shallowRef, computed, watch, watchEffect, effectScope, lifecycle hooks, composables core-new-apis

Features

Topic Description Reference
Built-in Components & Directives Transition, Teleport, Suspense, KeepAlive, v-memo, custom directives advanced-patterns

Quick Reference

Component Template

<script setup lang="ts">
import { ref, computed, watch, onMounted } from 'vue'

const props = defineProps<{
  title: string
  count?: number
}>()

const emit = defineEmits<{
  update: [value: string]
}>()

const model = defineModel<string>()

const doubled = computed(() => (props.count ?? 0) * 2)

watch(() => props.title, (newVal) => {
  console.log('Title changed:', newVal)
})

onMounted(() => {
  console.log('Component mounted')
})
</script>

<template>
  <div>{{ title }} - {{ doubled }}</div>
</template>

Key Imports

// Reactivity
import { ref, shallowRef, computed, reactive, readonly, toRef, toRefs, toValue } from 'vue'

// Watchers
import { watch, watchEffect, watchPostEffect, onWatcherCleanup } from 'vue'

// Lifecycle
import { onMounted, onUpdated, onUnmounted, onBeforeMount, onBeforeUpdate, onBeforeUnmount } from 'vue'

// Utilities
import { nextTick, defineComponent, defineAsyncComponent } from 'vue'
Câu hỏi thường gặp

Skill có dùng Options API không?

Không. Skill khuyên dùng Composition API thay vì Options API.

Skill ưu tiên kiểu script nào?

Skill ưu tiên script setup với lang ts, giúp component ngắn gọn và có kiểu dữ liệu.

Skill có bao quát các component có sẵn không?

Có. Skill bao quát Transition, Teleport, Suspense và KeepAlive.

Chi tiết

Mô tả gốc của tác giả

Vue 3 Composition API, script setup macros, reactivity system, and built-in components. Use when writing Vue SFCs, defineProps/defineEmits/defineModel, watchers, or using Transition/Teleport/Suspense/KeepAlive.

repo: antfu/skills

Độ phổ biến

Sao GitHub
6.0k
Vị trí xếp hạng
#14448
Giấy phép
MIT
Cập nhật
30/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự