1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <script setup lang="ts">
| import type { PropType } from 'vue';
|
| import { Button } from 'ant-design-vue';
|
| defineProps({
| categoryList: {
| type: Array as PropType<string[]>,
| required: true,
| },
| active: {
| type: String,
| required: false,
| default: '全部',
| },
| });
|
| const emits = defineEmits(['onCategoryClick']); // 定义回调
|
| /** 处理分类点击事件 */
| async function handleCategoryClick(category: string) {
| emits('onCategoryClick', category);
| }
| </script>
|
| <template>
| <div class="mx-0 flex flex-wrap items-center">
| <div
| class="mr-2 flex flex-row"
| v-for="category in categoryList"
| :key="category"
| >
| <Button
| size="small"
| shape="round"
| :type="category === active ? 'primary' : 'default'"
| @click="handleCategoryClick(category)"
| >
| {{ category }}
| </Button>
| </div>
| </div>
| </template>
|
|