| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <template>
- <ElButton
- :type="type"
- :loading="loading"
- :disabled="disabled"
- :size="size"
- :class="{ square }"
- v-bind="$attrs"
- >
- <Icon :icon="icon" :color="iconColor" :width="iconSize" :height="iconSize"></Icon>
- <slot>{{ label }}</slot>
- </ElButton>
- </template>
- <script setup lang="ts">
- import { ElButton } from 'element-plus'
- import Icon from '../icon/Icon.vue'
- import { computed } from 'vue'
- const props = withDefaults(
- defineProps<{
- icon: string
- iconColor?: string
- size?: 'small' | 'large' | 'default'
- loading?: boolean
- type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default'
- disabled?: boolean
- square?: boolean
- label?: string
- }>(),
- {
- size: 'default',
- type: 'default',
- loading: false
- }
- )
- const iconSize = computed(() => (props.size === 'large' ? 20 : props.size === 'small' ? 12 : 16))
- </script>
- <style lang="less" scoped>
- .square {
- &.el-button {
- padding: 8px;
- &--large {
- padding: 12px;
- }
- &--small {
- padding: 5px;
- }
- }
- }
- </style>
|