zhuoyuan.wang
2024-06-19 15ebe96f28cadec6a726c5324593a40bbf56205f
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
44
45
46
<template>
  <el-dropdown  @command="onCommand">
    <el-button>
      <el-icon>
        <Monitor/>
      </el-icon>
    </el-button>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item :command="item.name" v-for="item in columns" :disabled="active === item.name">{{item.label}}</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
 
<script setup>
 
const props = defineProps({
  subActive: {
    type: Function,
    default: () => {
    }
  }
});
 
const active = ref('table');
 
const columns = [
  {
    label: '列表',
    name: 'table'
  }, {
    label: '卡片',
    name: 'card'
  }
];
 
const onCommand = (command) => {
  active.value = command;
  props.subActive(command);
}
 
</script>
 
<style lang='scss' scoped>
</style>