Back to Registry
View Author Profile
Official Verified
Vue3+AntDesignVue组件封装
用于封装基于 Vue 3 + Ant Design Vue 的通用业务组件,提供标准化组件封装模板和最佳实践。
skill-install — Terminal
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/94lfj/vue3-ant-design-vue-component-skillOr
一、核心规范
1. 技术栈
- 框架:Vue 3.4+
- UI库:Ant Design Vue
- 语言:JavaScript
- 样式:Less
- 构建:Vite
2. 命名规范
- 文件夹:kebab-case(search-form)
- 组件名:PascalCase(SearchForm)
- Props/Events:camelCase
- 样式类:kebab-case(.search-form-container)
3. 文件结构
ComponentName/ ├── index.vue ├── types.js(可选) ├── composables/ ├── components/ └── index.js
二、基础组件模板(Card容器)
<template>
<div class="base-card-container">
<a-card :loading="loading">
<template #title>
<div class="card-header">
<span>{{ title }}</span>
<div class="header-actions">
<slot name="header-actions" />
</div>
</div>
</template>
<div class="card-content">
<slot />
</div>
<div v-if="showFooter" class="card-footer">
<slot name="footer">
<a-button @click="handleCancel">取消</a-button>
<a-button type="primary" :loading="submitLoading" @click="handleSubmit">
确定
</a-button>
</slot>
</div>
</a-card>
</div>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
const props = defineProps({
title: { type: String, default: '' },
loading: { type: Boolean, default: false },
showFooter: { type: Boolean, default: true },
submitLoading: { type: Boolean, default: false },
data: { type: Object, default: () => ({}) }
});
const emit = defineEmits(['update:loading', 'submit', 'cancel', 'change']);
const internalLoading = ref(false);
const actualLoading = computed({
get: () => props.loading ?? internalLoading.value,
set: (val) => {
internalLoading.value = val;
emit('update:loading', val);
}
});
const handleSubmit = async () => {
try {
actualLoading.value = true;
emit('submit', props.data);
} finally {
actualLoading.value = false;
}
};
const handleCancel = () => {
emit('cancel');
};
watch(
() => props.data,
(val) => emit('change', val),
{ deep: true }
);
defineExpose({
loading: actualLoading,
handleSubmit,
handleCancel
});
</script>
<style lang="less" scoped>
.base-card-container {
width: 100%;
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.header-actions {
display: flex;
gap: 8px;
}
.card-footer {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 16px;
border-top: 1px solid var(--ant-border-color-split);
padding-top: 12px;
}
}
</style>
三、表单组件(DynamicForm)
Metadata
AI Skill Finder
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skill Add to Configuration
Paste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-94lfj-vue3-ant-design-vue-component-skill": {
"enabled": true,
"auto_update": true
}
}
}Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.