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
| <template>
| <div class="flex flex-row flex-wrap items-center">
| <div class="flex flex-row mr-10px" v-for="category in categoryList" :key="category">
| <el-button
| plain
| round
| size="small"
| :type="category === active ? 'primary' : ''"
| @click="handleCategoryClick(category)"
| >
| {{ category }}
| </el-button>
| </div>
| </div>
| </template>
| <script setup lang="ts">
| import { PropType } from 'vue'
|
| // 定义属性
| defineProps({
| categoryList: {
| type: Array as PropType<string[]>,
| required: true
| },
| active: {
| type: String,
| required: false,
| default: '全部'
| }
| })
|
| // 定义回调
| const emits = defineEmits(['onCategoryClick'])
|
| /** 处理分类点击事件 */
| const handleCategoryClick = async (category: string) => {
| emits('onCategoryClick', category)
| }
| </script>
|
|