index.vue 593 B

1234567891011121314151617181920212223242526272829303132333435
  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 :size="20" class="icon">
  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. }
  29. </style>