king-design-analyzer 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/components/actions.json +8 -0
  2. package/components/advancedset.json +1 -0
  3. package/components/affix.json +1 -0
  4. package/components/anchor.json +220 -0
  5. package/components/anchorlink.json +111 -0
  6. package/components/badge.json +1 -0
  7. package/components/breadcrumb.json +2 -1
  8. package/components/button.json +1 -0
  9. package/components/buttonlink.json +1 -0
  10. package/components/card.json +6 -3
  11. package/components/cardcontent.json +5 -0
  12. package/components/cascader.json +56 -0
  13. package/components/collapse.json +335 -348
  14. package/components/configprovider.json +96 -0
  15. package/components/copyrow.json +1 -0
  16. package/components/descriptions.json +10 -3
  17. package/components/diagram.json +295 -0
  18. package/components/dialog.json +4 -0
  19. package/components/divider.json +1 -0
  20. package/components/drawer.json +32 -0
  21. package/components/dropdown.json +13 -4
  22. package/components/flex.json +1 -0
  23. package/components/form.json +12 -3
  24. package/components/header.json +4 -0
  25. package/components/input.json +8 -4
  26. package/components/layoutcontent.json +9 -0
  27. package/components/layoutlistcontent.json +9 -0
  28. package/components/layoutpermissioncontent.json +1 -0
  29. package/components/layoutstandardlist.json +1 -0
  30. package/components/lazymount.json +1 -0
  31. package/components/lazyteleport.json +1 -0
  32. package/components/menu.json +4 -3
  33. package/components/notification.json +351 -0
  34. package/components/popover.json +23 -0
  35. package/components/protable.json +2 -0
  36. package/components/rate.json +1 -0
  37. package/components/scrollselect.json +140 -0
  38. package/components/select.json +72 -0
  39. package/components/skeleton.json +1 -0
  40. package/components/slider.json +12 -2
  41. package/components/spin.json +2 -1
  42. package/components/spinner.json +422 -428
  43. package/components/split.json +3 -0
  44. package/components/switch.json +4 -2
  45. package/components/table.json +6 -1
  46. package/components/tabs.json +2 -2
  47. package/components/tag.json +8 -5
  48. package/components/timeline.json +3 -1
  49. package/components/tip.json +20 -0
  50. package/components/tooltip.json +8 -0
  51. package/components/tour.json +16 -0
  52. package/components/transfer.json +52 -5
  53. package/components/tree.json +22 -1
  54. package/components/treeselect.json +56 -0
  55. package/components/upload.json +16 -0
  56. package/components/vdialog.json +1 -0
  57. package/components/vdrawer.json +4 -0
  58. package/components/virtuallist.json +9 -0
  59. package/dist/ast/index.d.mts +30 -1
  60. package/dist/ast/index.d.ts +30 -1
  61. package/dist/ast/index.js +3 -3
  62. package/dist/ast/index.mjs +1 -1
  63. package/dist/{chunk-BI5TIQID.mjs → chunk-4OTQAQ6J.mjs} +13 -2
  64. package/dist/chunk-6HOIRUQB.mjs +409 -0
  65. package/dist/{chunk-XGPHQHLR.mjs → chunk-BSCASJTV.mjs} +27 -4
  66. package/dist/{chunk-CR3GC4H3.js → chunk-DHLWNT53.js} +13 -2
  67. package/dist/{chunk-CJGGFVQJ.js → chunk-HARQRI4F.js} +31 -8
  68. package/dist/{chunk-TA3SV4SP.js → chunk-JJ6AB4ZH.js} +2 -2
  69. package/dist/{chunk-3LYQ5XFM.mjs → chunk-NZL6T22V.mjs} +1 -1
  70. package/dist/chunk-V5N65MRP.js +411 -0
  71. package/dist/{chunk-SZYVGYKK.js → chunk-XPHDD6XR.js} +113 -35
  72. package/dist/{chunk-KMIDURUR.mjs → chunk-YRGYDK2I.mjs} +113 -35
  73. package/dist/full/index.d.mts +2 -0
  74. package/dist/full/index.d.ts +2 -0
  75. package/dist/full/index.js +6 -6
  76. package/dist/full/index.mjs +4 -4
  77. package/dist/index.js +13 -13
  78. package/dist/index.mjs +5 -5
  79. package/dist/metadata/index.d.mts +17 -2
  80. package/dist/metadata/index.d.ts +17 -2
  81. package/dist/runtime/index.d.mts +2 -0
  82. package/dist/runtime/index.d.ts +2 -0
  83. package/dist/runtime/index.js +4 -4
  84. package/dist/runtime/index.mjs +2 -2
  85. package/dist/static/index.js +5 -5
  86. package/dist/static/index.mjs +2 -2
  87. package/docs_for_llm/actions.doc.md +11 -1
  88. package/docs_for_llm/advancedset.doc.md +10 -1
  89. package/docs_for_llm/affix.doc.md +5 -0
  90. package/docs_for_llm/anchor.doc.md +155 -0
  91. package/docs_for_llm/anchorlink.doc.md +75 -0
  92. package/docs_for_llm/badge.doc.md +5 -0
  93. package/docs_for_llm/breadcrumb.doc.md +74 -1
  94. package/docs_for_llm/button.doc.md +57 -0
  95. package/docs_for_llm/buttonlink.doc.md +10 -1
  96. package/docs_for_llm/card.doc.md +50 -3
  97. package/docs_for_llm/cardcontent.doc.md +21 -0
  98. package/docs_for_llm/carousel.doc.md +71 -0
  99. package/docs_for_llm/cascader.doc.md +62 -0
  100. package/docs_for_llm/collapse.doc.md +138 -8
  101. package/docs_for_llm/configprovider.doc.md +77 -0
  102. package/docs_for_llm/copyrow.doc.md +10 -1
  103. package/docs_for_llm/datepicker.doc.md +19 -0
  104. package/docs_for_llm/descriptions.doc.md +113 -4
  105. package/docs_for_llm/diagram.doc.md +343 -0
  106. package/docs_for_llm/dialog.doc.md +49 -0
  107. package/docs_for_llm/divider.doc.md +5 -0
  108. package/docs_for_llm/drawer.doc.md +86 -0
  109. package/docs_for_llm/dropdown.doc.md +257 -3
  110. package/docs_for_llm/flex.doc.md +10 -1
  111. package/docs_for_llm/form.doc.md +163 -4
  112. package/docs_for_llm/formitemspinner.doc.md +1 -1
  113. package/docs_for_llm/grid.doc.md +71 -0
  114. package/docs_for_llm/header.doc.md +33 -4
  115. package/docs_for_llm/input.doc.md +109 -2
  116. package/docs_for_llm/layoutcontent.doc.md +37 -0
  117. package/docs_for_llm/layoutlistcontent.doc.md +82 -9
  118. package/docs_for_llm/layoutpermissioncontent.doc.md +10 -1
  119. package/docs_for_llm/layoutstandardlist.doc.md +10 -1
  120. package/docs_for_llm/lazymount.doc.md +10 -1
  121. package/docs_for_llm/lazyteleport.doc.md +10 -1
  122. package/docs_for_llm/menu.doc.md +125 -3
  123. package/docs_for_llm/message.doc.md +45 -0
  124. package/docs_for_llm/notification.doc.md +214 -0
  125. package/docs_for_llm/popover.doc.md +34 -0
  126. package/docs_for_llm/protable.doc.md +9 -0
  127. package/docs_for_llm/rate.doc.md +5 -0
  128. package/docs_for_llm/scrollselect.doc.md +90 -0
  129. package/docs_for_llm/select.doc.md +189 -0
  130. package/docs_for_llm/skeleton.doc.md +35 -0
  131. package/docs_for_llm/slider.doc.md +11 -1
  132. package/docs_for_llm/spin.doc.md +10 -1
  133. package/docs_for_llm/spinner.doc.md +1 -1
  134. package/docs_for_llm/split.doc.md +13 -0
  135. package/docs_for_llm/steps.doc.md +71 -0
  136. package/docs_for_llm/switch.doc.md +15 -2
  137. package/docs_for_llm/table.doc.md +199 -4
  138. package/docs_for_llm/tabs.doc.md +98 -2
  139. package/docs_for_llm/tag.doc.md +148 -5
  140. package/docs_for_llm/timeline.doc.md +80 -2
  141. package/docs_for_llm/timepicker.doc.md +19 -0
  142. package/docs_for_llm/tip.doc.md +30 -0
  143. package/docs_for_llm/tooltip.doc.md +46 -0
  144. package/docs_for_llm/tour.doc.md +102 -0
  145. package/docs_for_llm/transfer.doc.md +59 -4
  146. package/docs_for_llm/tree.doc.md +64 -1
  147. package/docs_for_llm/treeselect.doc.md +68 -0
  148. package/docs_for_llm/upload.doc.md +28 -0
  149. package/docs_for_llm/vdialog.doc.md +26 -1
  150. package/docs_for_llm/vdrawer.doc.md +33 -4
  151. package/docs_for_llm/virtuallist.doc.md +165 -0
  152. package/package.json +3 -3
  153. package/dist/chunk-D2SXGGTX.mjs +0 -162
  154. package/dist/chunk-EYKZY2F3.js +0 -164
@@ -19,7 +19,7 @@ import { Spinner } from '@king-design/vue';
19
19
  | max | `number` | `Number.POSITIVE_INFINITY` | 否 | 最大值 | - | `<Spinner :max="100" />` |
20
20
  | min | `number` | `Number.NEGATIVE_INFINITY` | 否 | 最小值 | - | `<Spinner :min="0" />` |
21
21
  | step | `number | StepObject | StepFunction` | `1` | 否 | 步长,支持数字、对象或函数形式的动态步长 | - | `<Spinner :step="5" />` |
22
- | size | `"default" | "small" | "mini"` | `"default"` | 否 | 尺寸 | - | `<Spinner size="small" />` |
22
+ | size | `"large" | "default" | "small" | "mini"` | `"default"` | 否 | 尺寸 | - | `<Spinner size="small" />` |
23
23
  | vertical | `boolean` | `false` | 否 | 控制按钮是否竖直排列 | - | `<Spinner vertical />` |
24
24
  | precision | `number` | `undefined` | 否 | 控制展示精度,该值必须为正整数或 0 | - | `<Spinner :precision="2" :step="0.1" />` |
25
25
  | formatter | `(value: number) => string` | `undefined` | 否 | 定义格式化展示值的函数 | - | `<Spinner :formatter="(val) => `${val}%`" :parser="(val) => parseFloat(val)" /></Spinner>` |
@@ -74,6 +74,19 @@ const handleMoveEnd = (e?: MouseEvent) => {
74
74
  | last | 第二个面板内容。 | `<template #last>...</template>` | `<Split><template #first>左侧内容</template><template #last>右侧内容</template></Split>` |
75
75
  | drag | 自定义拖拽分割条内容。 | `<template #drag>...</template>` | `<Split><template #drag><div class="custom-handle" /></template></Split>` |
76
76
 
77
+ ### 插槽参数说明
78
+ **first**
79
+
80
+ - 参数结构: 无参数
81
+
82
+ **last**
83
+
84
+ - 参数结构: 无参数
85
+
86
+ **drag**
87
+
88
+ - 参数结构: 无参数
89
+
77
90
  ## 常见错误与正确用法 (Anti-Hallucination)
78
91
  ### 未使用 first 和 last 命名插槽
79
92
  > **错误用法**: `<Split>
@@ -24,10 +24,81 @@ import { Steps, Step } from '@king-design/vue';
24
24
  ### Step
25
25
  步骤项组件,用于定义每个步骤的标题和内容
26
26
 
27
+ #### 属性 (Props)
27
28
  | 属性名 | 类型 | 说明 | 示例 |
28
29
  | --- | --- | --- | --- |
29
30
  | title | `string` | 步骤标题 | `<Step title="步骤1" />` |
30
31
 
32
+ #### 组合示例
33
+ ##### 基础用法
34
+ **场景**: 创建一个基本的步骤条
35
+
36
+ 基本的步骤条
37
+
38
+ **命中的子组件 API**: 属性: title
39
+
40
+ ```vue
41
+ <script setup lang="ts">
42
+ import { ref } from 'vue';
43
+ import { Steps, Step } from '@king-design/vue';
44
+
45
+ const current = ref(1);
46
+ </script>
47
+ <template>
48
+ <Steps :value="current">
49
+ <Step title="步骤1" />
50
+ <Step title="步骤2" />
51
+ <Step title="步骤3" />
52
+ </Steps>
53
+ </template>
54
+ ```
55
+
56
+ ##### 可点击切换
57
+ **场景**: 可以点击已完成的步骤进行切换
58
+
59
+ 支持点击切换已完成的步骤
60
+
61
+ **命中的子组件 API**: 属性: title
62
+
63
+ ```vue
64
+ <script setup lang="ts">
65
+ import { ref } from 'vue';
66
+ import { Steps, Step } from '@king-design/vue';
67
+
68
+ const current = ref(0);
69
+ </script>
70
+ <template>
71
+ <Steps v-model="current" clickable>
72
+ <Step title="填写信息" />
73
+ <Step title="确认信息" />
74
+ <Step title="完成" />
75
+ </Steps>
76
+ </template>
77
+ ```
78
+
79
+ ##### 垂直步骤条
80
+ **场景**: 创建垂直排列的步骤条
81
+
82
+ 垂直排列的步骤条
83
+
84
+ **命中的子组件 API**: 属性: title
85
+
86
+ ```vue
87
+ <script setup lang="ts">
88
+ import { ref } from 'vue';
89
+ import { Steps, Step } from '@king-design/vue';
90
+
91
+ const current = ref(1);
92
+ </script>
93
+ <template>
94
+ <Steps :value="current" vertical>
95
+ <Step title="步骤1" />
96
+ <Step title="步骤2" />
97
+ <Step title="步骤3" />
98
+ </Steps>
99
+ </template>
100
+ ```
101
+
31
102
  ## 常见错误与正确用法 (Anti-Hallucination)
32
103
  ### value 从 1 开始而非 0
33
104
  > **错误用法**: `const current = ref(1); // 期望第一步
@@ -30,8 +30,21 @@ import { Switch } from '@king-design/vue';
30
30
  ## 插槽 (Slots)
31
31
  | 插槽名 | 说明 | 模板写法 | 示例 |
32
32
  | --- | --- | --- | --- |
33
- | on | 扩展开启时的文案 | `undefined` | - |
34
- | off | 扩展关闭时的文案 | `undefined` | - |
33
+ | on | 扩展开启时的文案 | `#on` | `<Switch>
34
+ <template #on>自定义on内容</template>
35
+ </Switch>` |
36
+ | off | 扩展关闭时的文案 | `#off` | `<Switch>
37
+ <template #off>自定义off内容</template>
38
+ </Switch>` |
39
+
40
+ ### 插槽参数说明
41
+ **on**
42
+
43
+ - 参数结构: 无参数
44
+
45
+ **off**
46
+
47
+ - 参数结构: 无参数
35
48
 
36
49
  ## 常见错误与正确用法 (Anti-Hallucination)
37
50
  ### 在 Vue 中使用保留字 Switch
@@ -168,6 +168,25 @@ const handlePage = (pageInfo: {value: number, limit: number}) => {
168
168
  </template>
169
169
  </Table>` |
170
170
 
171
+ ### 插槽参数说明
172
+ **empty**
173
+
174
+ - 参数结构: 无参数
175
+
176
+ **expand**
177
+
178
+ - 参数结构: #expand="[row, index]"
179
+ - 参数列表: `row: T`、`index: number`
180
+
181
+ **footer**
182
+
183
+ - 参数结构: 无参数
184
+
185
+ **tooltip**
186
+
187
+ - 参数结构: #tooltip="[data, index]"
188
+ - 参数列表: `data: T`、`index: number`
189
+
171
190
  ## 方法 (Methods)
172
191
  | 方法名 | 说明 | 参数 | 返回值 |
173
192
  | --- | --- | --- | --- |
@@ -186,12 +205,22 @@ const handlePage = (pageInfo: {value: number, limit: number}) => {
186
205
  | --- | --- | --- | --- | --- |
187
206
  | index | `number` | 是 | - | 行索引 |
188
207
 
208
+ 调用示例:
209
+ ```typescript
210
+ await tableRef.value?.scrollToRowByIndex(10);
211
+ ```
212
+
189
213
  **scrollToRowByKey**
190
214
 
191
215
  | 参数 | 类型 | 必填 | 默认值 | 说明 |
192
216
  | --- | --- | --- | --- | --- |
193
217
  | key | `TableRowKey` | 是 | - | 行key |
194
218
 
219
+ 调用示例:
220
+ ```typescript
221
+ await tableRef.value?.scrollToRowByKey('row-id-123');
222
+ ```
223
+
195
224
  **exportTable**
196
225
 
197
226
  | 参数 | 类型 | 必填 | 默认值 | 说明 |
@@ -199,10 +228,60 @@ const handlePage = (pageInfo: {value: number, limit: number}) => {
199
228
  | data | `T[]` | 否 | `this.data` | 要导出的数据 |
200
229
  | filename | `string` | 否 | `"table"` | 导出文件名 |
201
230
 
231
+ 调用示例:
232
+ ```typescript
233
+ const content = await tableRef.value?.exportTable(data.value, 'users');
234
+ ```
235
+
236
+ ### 方法调用示例
237
+ **getCheckedData**
238
+
239
+ ```typescript
240
+ const tableRef = ref<InstanceType<typeof Table>>();
241
+ const checkedData = tableRef.value?.getCheckedData();</InstanceType>
242
+ ```
243
+
244
+ **getSelectedData**
245
+
246
+ ```typescript
247
+ const selectedData = tableRef.value?.getSelectedData();
248
+ ```
249
+
250
+ **checkAll**
251
+
252
+ ```typescript
253
+ tableRef.value?.checkAll();
254
+ ```
255
+
256
+ **uncheckAll**
257
+
258
+ ```typescript
259
+ tableRef.value?.uncheckAll();
260
+ ```
261
+
262
+ **scrollToRowByIndex**
263
+
264
+ ```typescript
265
+ await tableRef.value?.scrollToRowByIndex(10);
266
+ ```
267
+
268
+ **scrollToRowByKey**
269
+
270
+ ```typescript
271
+ await tableRef.value?.scrollToRowByKey('row-id-123');
272
+ ```
273
+
274
+ **exportTable**
275
+
276
+ ```typescript
277
+ const content = await tableRef.value?.exportTable(data.value, 'users');
278
+ ```
279
+
202
280
  ## 子组件 (Sub-Components)
203
281
  ### TableColumn
204
282
  表格列定义
205
283
 
284
+ #### 属性 (Props)
206
285
  | 属性名 | 类型 | 说明 | 示例 |
207
286
  | --- | --- | --- | --- |
208
287
  | key | `string` | 指定当前列的key,必须指定 | `<TableColumn key="name" title="姓名" />` |
@@ -222,10 +301,126 @@ const handlePage = (pageInfo: {value: number, limit: number}) => {
222
301
  | hidden | `boolean` | 是否隐藏当前列,仅为不可见,不影响exportTable导出表格 | - |
223
302
  | ellipsis | `boolean` | 是否开启超长省略 | `<TableColumn key="desc" title="描述" ellipsis />` |
224
303
 
225
- **插槽**:
226
- - `#title`: 自定义复杂表头内容
227
- - `#template="[data, index]"`: 自定义单元格内容
228
- - `#default="[data, index]"`: 与template扩展点等价,为了方便vue中使用的别名
304
+ #### 插槽 (Slots)
305
+ | 插槽名 | 说明 | 模板写法 | 示例 |
306
+ | --- | --- | --- | --- |
307
+ | title | 自定义复杂表头内容 | `#title` | `<TableColumn key="custom">
308
+ <template #title>自定义表头</template>
309
+ </TableColumn>` |
310
+ | template | 自定义单元格内容 | `#template="[data, index]"` | `<TableColumn key="action" title="操作">
311
+ <template #template="[data]">
312
+ <Button @click="handleEdit(data)">编辑</Button>
313
+ </template>
314
+ </TableColumn>` |
315
+ | default | 与template扩展点等价,为了方便vue中使用的别名 | `#default="[data, index]"` | `<TableColumn key="action" title="操作">
316
+ <template #default="[data]">
317
+ <Button @click="handleEdit(data)">编辑</Button>
318
+ </template>
319
+ </TableColumn>` |
320
+
321
+ ##### 插槽参数说明
322
+ **title**
323
+
324
+ - 参数结构: 无参数
325
+
326
+ **template**
327
+
328
+ - 参数结构: #template="[data, index]"
329
+ - 参数列表: `data: T`、`index: number`
330
+
331
+ **default**
332
+
333
+ - 参数结构: #default="[data, index]"
334
+ - 参数列表: `data: T`、`index: number`
335
+
336
+ #### 组合示例
337
+ ##### 自定义单元格
338
+ **场景**: 创建带有状态标签和操作按钮的表格
339
+
340
+ 使用插槽自定义单元格内容
341
+
342
+ **命中的子组件 API**: 属性: key, title | 插槽: default
343
+
344
+ ```vue
345
+ <script setup lang="ts">
346
+ import { ref } from 'vue';
347
+ import { Table, TableColumn, Button, Tag } from '@king-design/vue';
348
+
349
+ const data = ref([
350
+ { name: '张三', status: 'active' },
351
+ { name: '李四', status: 'inactive' }
352
+ ]);
353
+ </script>
354
+ <template>
355
+ <Table :data="data">
356
+ <TableColumn key="name" title="姓名" />
357
+ <TableColumn key="status" title="状态">
358
+ <template #default="[row]">
359
+ <Tag :type="row.status === 'active' ? 'success' : 'warning'">
360
+ {{ row.status === 'active' ? '激活' : '未激活' }}
361
+ </Tag>
362
+ </template>
363
+ </TableColumn>
364
+ <TableColumn key="action" title="操作">
365
+ <template #default="[row]">
366
+ <Button type="primary" size="small">编辑</Button>
367
+ </template>
368
+ </TableColumn>
369
+ </Table>
370
+ </template>
371
+ ```
372
+
373
+ ##### 基础表格
374
+ **场景**: 创建一个简单的表格展示用户信息
375
+
376
+ 展示基本的表格用法
377
+
378
+ **命中的子组件 API**: 属性: key, title
379
+
380
+ ```vue
381
+ <script setup lang="ts">
382
+ import { ref } from 'vue';
383
+ import { Table, TableColumn } from '@king-design/vue';
384
+
385
+ const data = ref([
386
+ { name: '张三', age: 25, address: '北京' },
387
+ { name: '李四', age: 30, address: '上海' }
388
+ ]);
389
+ </script>
390
+ <template>
391
+ <Table :data="data">
392
+ <TableColumn key="name" title="姓名" />
393
+ <TableColumn key="age" title="年龄" />
394
+ <TableColumn key="address" title="地址" />
395
+ </Table>
396
+ </template>
397
+ ```
398
+
399
+ ##### 可选择表格
400
+ **场景**: 创建一个可多选的表格,支持获取选中行
401
+
402
+ 支持行选择的表格
403
+
404
+ **命中的子组件 API**: 属性: key, title
405
+
406
+ ```vue
407
+ <script setup lang="ts">
408
+ import { ref } from 'vue';
409
+ import { Table, TableColumn } from '@king-design/vue';
410
+
411
+ const data = ref([
412
+ { id: 1, name: '张三' },
413
+ { id: 2, name: '李四' }
414
+ ]);
415
+ const checkedKeys = ref<number[]>([]);
416
+ </script>
417
+ <template>
418
+ <Table :data="data" checkType="checkbox" v-model:checkedKeys="checkedKeys" :rowKey="row => row.id">
419
+ <TableColumn key="name" title="姓名" />
420
+ </Table>
421
+ <p>选中: {{ checkedKeys }}</p>
422
+ </template>
423
+ ```
229
424
 
230
425
  ## 常见错误与正确用法 (Anti-Hallucination)
231
426
  ### TableColumn 作用域插槽参数解构方式错误
@@ -45,6 +45,7 @@ const handleRemove = (value: string) => {
45
45
  ### Tab
46
46
  选项卡项组件
47
47
 
48
+ #### 属性 (Props)
48
49
  | 属性名 | 类型 | 说明 | 示例 |
49
50
  | --- | --- | --- | --- |
50
51
  | value | `any` | 选项卡的值,用于标识和选中 | `<Tab value="home">首页</Tab>` |
@@ -52,8 +53,103 @@ const handleRemove = (value: string) => {
52
53
  | to | `string` | 点击标签的跳转地址 | `<Tab value="home" to="/home">首页</Tab>` |
53
54
  | closable | `boolean` | 是否展示该选项卡的关闭按钮 | `<Tab value="tab" closable>可关闭</Tab>` |
54
55
 
55
- **事件**:
56
- - `@click`: Tab 点击事件,发生在 value 改变之后,disabled 状态不触发
56
+ #### 事件 (Events)
57
+ | 事件名 | Vue事件名 | 说明 | 回调参数 | 示例 |
58
+ | --- | --- | --- | --- | --- |
59
+ | click | `@click` | Tab 点击事件,发生在 value 改变之后,disabled 状态不触发 | `e: MouseEvent` | `<Tab @click="handleTabClick"></Tab>` |
60
+
61
+ ##### Tab 事件参数说明
62
+ **click**
63
+
64
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
65
+ | --- | --- | --- | --- | --- |
66
+ | e | `MouseEvent` | 是 | - | 原生鼠标事件 |
67
+
68
+ 事件处理示例:
69
+ ```typescript
70
+ const openInNewWindow = ref(false);
71
+
72
+ const handleTabClick = (e: MouseEvent) => {
73
+ openInNewWindow.value = e.metaKey || e.ctrlKey;
74
+ };
75
+ ```
76
+
77
+ #### 组合示例
78
+ ##### 禁用选项卡
79
+ **场景**: 禁用某个选项卡
80
+
81
+ 禁用某个选项卡
82
+
83
+ **命中的子组件 API**: 属性: value, disabled
84
+
85
+ ```vue
86
+ <script setup lang="ts">
87
+ import { ref } from 'vue';
88
+ import { Tabs, Tab } from '@king-design/vue';
89
+
90
+ const activeTab = ref('tab1');
91
+ </script>
92
+ <template>
93
+ <Tabs v-model="activeTab">
94
+ <Tab value="tab1">可用</Tab>
95
+ <Tab value="tab2" disabled>禁用</Tab>
96
+ <Tab value="tab3">可用</Tab>
97
+ </Tabs>
98
+ </template>
99
+ ```
100
+
101
+ ##### 路由导航
102
+ **场景**: 使用 to 属性进行路由导航
103
+
104
+ 配合路由使用的选项卡
105
+
106
+ **命中的子组件 API**: 属性: value, to
107
+
108
+ ```vue
109
+ <script setup lang="ts">
110
+ import { ref } from 'vue';
111
+ import { Tabs, Tab } from '@king-design/vue';
112
+
113
+ const activeTab = ref('home');
114
+ </script>
115
+ <template>
116
+ <Tabs v-model="activeTab">
117
+ <Tab value="home" to="/">首页</Tab>
118
+ <Tab value="products" to="/products">产品</Tab>
119
+ <Tab value="docs" to="/docs">文档</Tab>
120
+ </Tabs>
121
+ </template>
122
+ ```
123
+
124
+ ##### 可关闭选项卡
125
+ **场景**: 创建可关闭的选项卡
126
+
127
+ 支持关闭选项卡
128
+
129
+ **命中的子组件 API**: 属性: value, closable
130
+
131
+ ```vue
132
+ <script setup lang="ts">
133
+ import { ref } from 'vue';
134
+ import { Tabs, Tab } from '@king-design/vue';
135
+
136
+ const activeTab = ref('tab1');
137
+ const tabs = ref(['tab1', 'tab2', 'tab3']);
138
+
139
+ const handleRemove = (value: string) => {
140
+ const index = tabs.value.indexOf(value);
141
+ tabs.value.splice(index, 1);
142
+ if (activeTab.value === value && tabs.value.length > 0) {
143
+ activeTab.value = tabs.value[0];
144
+ }
145
+ };
146
+ </script>
147
+ <template>
148
+ <Tabs v-model="activeTab" closable @remove="handleRemove">
149
+ <Tab v-for="tab in tabs" :key="tab" :value="tab">{{ tab }}</Tab>
150
+ </Tabs>
151
+ </template>
152
+ ```
57
153
 
58
154
  ## 常见错误与正确用法 (Anti-Hallucination)
59
155
  ### 期望 Tabs 自动切换内容
@@ -44,6 +44,7 @@ const handleClose = (e: MouseEvent) => {
44
44
  ### Tags
45
45
  标签组容器,用于管理多个标签,支持单行展示和拖拽排序
46
46
 
47
+ #### 属性 (Props)
47
48
  | 属性名 | 类型 | 说明 | 示例 |
48
49
  | --- | --- | --- | --- |
49
50
  | size | `"large" | "default" | "small" | "mini"` | 定义"更多"标签尺寸 | `<Tags size="small"></Tags>` |
@@ -51,12 +52,154 @@ const handleClose = (e: MouseEvent) => {
51
52
  | nowrap | `boolean` | 是否单行展示标签组,超出的部分会隐藏,仅展示隐藏数量 | `<Tags nowrap></Tags>` |
52
53
  | draggable | `boolean` | 标签是否支持拖动排序 | `<Tags draggable></Tags>` |
53
54
 
54
- **事件**:
55
- - `@dragstart`: 拖动开始时触发
56
- - `@dragend`: 拖动结束时触发
55
+ #### 事件 (Events)
56
+ | 事件名 | Vue事件名 | 说明 | 回调参数 | 示例 |
57
+ | --- | --- | --- | --- | --- |
58
+ | dragstart | `@dragstart` | 拖动开始时触发 | `key: string | number, from: number` | `<Tags draggable @dragstart="handleTagDragStart"></Tags>` |
59
+ | dragend | `@dragend` | 拖动结束时触发 | `key: string | number, from: number, to: number` | `<Tags draggable @dragend="handleTagDragEnd"></Tags>` |
60
+
61
+ ##### Tags 事件参数说明
62
+ **dragstart**
63
+
64
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
65
+ | --- | --- | --- | --- | --- |
66
+ | key | `string | number` | 是 | - | 被拖拽标签的 key |
67
+ | from | `number` | 是 | - | 起始位置索引 |
68
+
69
+ 事件处理示例:
70
+ ```typescript
71
+ const draggingTagKey = ref<string | number | null>(null);
72
+
73
+ const handleTagDragStart = ({ key }) => {
74
+ draggingTagKey.value = key;
75
+ };
76
+ ```
77
+
78
+ **dragend**
79
+
80
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
81
+ | --- | --- | --- | --- | --- |
82
+ | key | `string | number` | 是 | - | 被拖拽标签的 key |
83
+ | from | `number` | 是 | - | 起始位置索引 |
84
+ | to | `number` | 是 | - | 目标位置索引 |
85
+
86
+ 事件处理示例:
87
+ ```typescript
88
+ const tags = ref(['稳定版', '灰度中', '待发布']);
89
+ const draggingTagKey = ref<string | number | null>(null);
90
+
91
+ const handleTagDragEnd = ({ from, to }) => {
92
+ const moved = tags.value.splice(from, 1)[0];
93
+ tags.value.splice(to, 0, moved);
94
+ draggingTagKey.value = null;
95
+ };
96
+ ```
97
+
98
+ #### 插槽 (Slots)
99
+ | 插槽名 | 说明 | 模板写法 | 示例 |
100
+ | --- | --- | --- | --- |
101
+ | append | 追加到后面的元素,不参与到Tags对Tag的管理中 | `#append` | `<Tags>
102
+ <Tag closable>标签一</Tag>
103
+ <template #append>
104
+ <Button type="link">新增标签</Button>
105
+ </template>
106
+ </Tags>` |
107
+
108
+ ##### 插槽参数说明
109
+ **append**
110
+
111
+ - 参数结构: 无参数
112
+
113
+ #### 组合示例
114
+ ##### 可拖拽排序
115
+ **场景**: 创建支持拖拽排序的标签组
116
+
117
+ 支持拖拽排序的标签组
118
+
119
+ **命中的子组件 API**: 属性: draggable | 事件: dragend
120
+
121
+ ```vue
122
+ <script setup lang="ts">
123
+ import { ref } from 'vue';
124
+ import { Tags, Tag, Message } from '@king-design/vue';
125
+
126
+ const tags = ref(['标签1', '标签2', '标签3', '标签4']);
127
+
128
+ const handleDragEnd = ({from, to}: {from: number; to: number}) => {
129
+ const tag = tags.value.splice(from, 1)[0];
130
+ tags.value.splice(to, 0, tag);
131
+ Message.success(`从 ${from} 移动到 ${to}`);
132
+ };
133
+ </script>
134
+ <template>
135
+ <Tags draggable @dragend="handleDragEnd">
136
+ <Tag v-for="tag in tags" :key="tag">{{ tag }}</Tag>
137
+ </Tags>
138
+ </template>
139
+ ```
140
+
141
+ ##### 单行标签组
142
+ **场景**: 在有限空间内展示标签,超出部分显示数量
143
+
144
+ 超出隐藏并显示隐藏数量
57
145
 
58
- **插槽**:
59
- - `undefined`: 追加到后面的元素,不参与到Tags对Tag的管理中
146
+ **命中的子组件 API**: 属性: nowrap
147
+
148
+ ```vue
149
+ <script setup lang="ts">
150
+ import { Tags, Tag } from '@king-design/vue';
151
+ </script>
152
+ <template>
153
+ <div style="width: 300px;">
154
+ <Tags nowrap>
155
+ <Tag>标签1</Tag>
156
+ <Tag>标签2</Tag>
157
+ <Tag>标签3</Tag>
158
+ <Tag>标签4</Tag>
159
+ <Tag>标签5</Tag>
160
+ <Tag>标签6</Tag>
161
+ </Tags>
162
+ </div>
163
+ </template>
164
+ ```
165
+
166
+ ##### 动态编辑标签
167
+ **场景**: 动态添加和删除标签的完整示例
168
+
169
+ 动态添加和删除标签
170
+
171
+ **命中的子组件 API**: 插槽: append
172
+
173
+ ```vue
174
+ <script setup lang="ts">
175
+ import { ref } from 'vue';
176
+ import { Tags, Tag, Button, Input } from '@king-design/vue';
177
+
178
+ const tags = ref(['标签1', '标签2']);
179
+ const inputValue = ref('');
180
+
181
+ const handleClose = (index: number) => {
182
+ tags.value.splice(index, 1);
183
+ };
184
+
185
+ const handleAdd = () => {
186
+ if (inputValue.value) {
187
+ tags.value.push(inputValue.value);
188
+ inputValue.value = '';
189
+ }
190
+ };
191
+ </script>
192
+ <template>
193
+ <Tags>
194
+ <Tag v-for="(tag, index) in tags" :key="tag"
195
+ closable @close="handleClose(index)">{{ tag }}</Tag>
196
+ <template #append>
197
+ <Input v-model="inputValue" :width="100" size="mini"
198
+ placeholder="新标签" @keydown.enter="handleAdd" />
199
+ </template>
200
+ </Tags>
201
+ </template>
202
+ ```
60
203
 
61
204
  ## 常见错误与正确用法 (Anti-Hallucination)
62
205
  ### 可关闭标签未使用受控模式