From 6ca7a8275c4ed13f391505c7b780ab0b44d81972 Mon Sep 17 00:00:00 2001 From: nanxun Date: Sun, 14 Dec 2025 14:12:47 +0800 Subject: [PATCH] =?UTF-8?q?add(MyButton):=20=E6=96=B0=E5=A2=9E=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/vue3组件文档.md | 150 ++++++++++++++++++ .../components/{MyInput.vue => IconInput.vue} | 0 frontend/web/src/components/MyButton.vue | 130 +++++++++++++++ frontend/web/src/views/Test.vue | 11 +- 4 files changed, 288 insertions(+), 3 deletions(-) create mode 100644 docs/vue3组件文档.md rename frontend/web/src/components/{MyInput.vue => IconInput.vue} (100%) create mode 100644 frontend/web/src/components/MyButton.vue diff --git a/docs/vue3组件文档.md b/docs/vue3组件文档.md new file mode 100644 index 0000000..a3631dd --- /dev/null +++ b/docs/vue3组件文档.md @@ -0,0 +1,150 @@ +# 📚 MyButton + +## 🏷️ 1. 组件概览 + +### 基础信息 + +| **属性** | **值** | +| ------------ | ---------------------------------------------------------- | +| **组件名称** | `MyButton` | +| **文件路径** | `@/components/MyButton.vue` | +| **用途** | 封装项目中的所有交互按钮,提供统一的样式、交互状态和动画。 | +| **版本** | v1.0.0 | +| **核心依赖** | `feather-icons` (需要父组件或全局初始化) | + +### 引入方式 + +JavaScript + +``` +import MyButton from '@/components/MyButton.vue'; +``` + +## 💡 2. 使用示例 + +### 基础用法(Primary Variant) + +HTML + +``` +保存配置 + + + + 发送邮件 + +``` + +### 状态和事件绑定 + +HTML + +``` + + 取消 + + + + 删除数据 + +``` + +## ⚙️ 3. Props 属性说明 (API) + +| **名称 (Prop Name)** | **类型 (Type)** | **可选值/说明** | **默认值 (Default)** | **描述** | +| -------------------- | --------------- | ------------------------------------------------------------ | -------------------- | -------------------------------------------------------- | +| `variant` | `String` | `primary` (主色调), `secondary` (次要/灰色), `danger` (危险/红色), `text` (纯文本链接样式) | `'primary'` | 定义按钮的外观和主题颜色。 | +| `disabled` | `Boolean` | — | `false` | 明确禁用按钮,移除点击交互和视觉提示。 | +| `loading` | `Boolean` | — | `false` | 设置为 `true` 时,按钮显示加载状态,并自动应用禁用样式。 | + +## 🧩 4. 插槽说明 (Slots) + +| **名称 (Slot Name)** | **用途** | **插槽 Prop** | **示例用法** | +| -------------------- | ------------------------------------------ | ------------- | --------------------------------- | +| **默认** (`default`) | 用于插入按钮的**文本内容**或其他核心元素。 | 无 | ` 按钮文本 ` | + +## ⚡ 5. 事件说明 (Events) + +| **名称 (Event Name)** | **参数 (Payload)** | **描述** | +| --------------------- | --------------------- | ------------------------------------------------------------ | +| `@click` | `(event: MouseEvent)` | 按钮被点击时触发。由于使用了 `v-bind="attrs"`,此事件是透传自内部 `