index.vue 634 B

123456789101112131415161718192021222324252627282930313233343536
  1. <script lang="ts" setup>
  2. import { Expand, Fold } from '@element-plus/icons-vue'
  3. interface Props {
  4. isActive?: boolean
  5. }
  6. const props = withDefaults(defineProps<Props>(), {
  7. isActive: false
  8. })
  9. /** Vue 3.3+ defineEmits 语法 */
  10. const emit = defineEmits<{
  11. toggleClick: []
  12. }>()
  13. const toggleClick = () => {
  14. emit('toggleClick')
  15. }
  16. </script>
  17. <template>
  18. <div @click="toggleClick">
  19. <el-icon class="icon" :size="20">
  20. <Fold v-if="props.isActive" />
  21. <Expand v-else />
  22. </el-icon>
  23. </div>
  24. </template>
  25. <style lang="scss" scoped>
  26. .icon {
  27. vertical-align: middle;
  28. color: var(--v3-hamburger-text-color);
  29. }
  30. </style>