Install
openclaw skills install gi-vue-component-guideDesign and implement Vue 3 components following best practices. Use when creating Vue components, defining props/emits, or when the user asks for Vue component structure or composition API patterns.
openclaw skills install gi-vue-component-guide按团队规范设计与实现 Vue 3 组件,适用于 Composition API + Ant Design 技术栈。
src/
├── components/ # 可复用组件
├── views/ # 页面级组件
├── router/
├── services/
├── stores/
├── types/
└── utils/
UserCard.vue、DataTable.vueuserName、isLoading<script setup lang="ts">
// 1. imports
// 2. props & emits 定义
// 3. 响应式状态
// 4. 计算属性
// 5. 方法
// 6. 生命周期 / watch
</script>
<template>
<!-- 模板 -->
</template>
<style scoped>
/* 样式 */
</style>
interface Props {
/** 用户 ID */
userId: number
/** 是否加载中 */
loading?: boolean
/** 自定义类名 */
class?: string
}
const props = withDefaults(defineProps<Props>(), {
loading: false
})
?withDefaultstypes/ 导入const emit = defineEmits<{
(e: 'update', value: string): void
(e: 'submit', payload: { id: number; name: string }): void
}>()
a-form + a-form-item,使用 v-model 或 v-decorator(视版本)a-table,columns 用 defineColumns 或常量a-modal,v-model:open 控制显隐a-button,type 区分 primary/default/danger// 从 services 调用 API
import { getUserList } from '@/services/user'
const loading = ref(false)
const data = ref<User[]>([])
async function fetchData() {
loading.value = true
try {
data.value = await getUserList(params)
} finally {
loading.value = false
}
}
types/ 或组件同目录interface 或 type,避免 any<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import type { User } from '@/types/user'
interface Props {
title?: string
}
const props = withDefaults(defineProps<Props>(), { title: '默认标题' })
const emit = defineEmits<{ (e: 'confirm', id: number): void }>()
const list = ref<User[]>([])
const loading = ref(false)
onMounted(() => {
// 初始化
})
</script>
<template>
<div class="user-card">
<a-spin :spinning="loading">
<!-- 内容 -->
</a-spin>
</div>
</template>
<style scoped>
.user-card { /* ... */ }
</style>
header、footer)scoped,避免污染;使用 CSS 变量统一主题