|
@ -1,23 +1,20 @@ |
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
import { ref } from 'vue' |
|
|
import { ref } from 'vue' |
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
|
|
type: { |
|
|
|
|
|
type: String, |
|
|
|
|
|
default: 'default', |
|
|
|
|
|
}, |
|
|
|
|
|
disabled: { |
|
|
|
|
|
type: Boolean, |
|
|
|
|
|
default: false, |
|
|
|
|
|
}, |
|
|
|
|
|
loading: { // 添加 loading 属性 |
|
|
|
|
|
type: Boolean, |
|
|
|
|
|
default: false, |
|
|
|
|
|
}, |
|
|
|
|
|
clickHandle: { |
|
|
|
|
|
type: Function, |
|
|
|
|
|
required: false, |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
interface FTButton { |
|
|
|
|
|
type?: 'default' | 'primary' | 'info' |
|
|
|
|
|
size?: 'small' | 'default' | 'large' |
|
|
|
|
|
disabled?: boolean |
|
|
|
|
|
loading?: boolean |
|
|
|
|
|
clickHandle?: () => any |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<FTButton>(), { |
|
|
|
|
|
type: 'default', |
|
|
|
|
|
size: 'default', |
|
|
|
|
|
disabled: false, |
|
|
|
|
|
loading: false, |
|
|
|
|
|
clickHandle: () => {}, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
const isLoading = ref(false) |
|
|
const isLoading = ref(false) |
|
@ -50,6 +47,7 @@ defineExpose({ |
|
|
<div |
|
|
<div |
|
|
class="my-button" :class="{ |
|
|
class="my-button" :class="{ |
|
|
[`my-button-${type}`]: true, |
|
|
[`my-button-${type}`]: true, |
|
|
|
|
|
[`my-button-${size}`]: true, |
|
|
'button-disabled': disabled || isLoading, // 添加 loading 判断 |
|
|
'button-disabled': disabled || isLoading, // 添加 loading 判断 |
|
|
}" |
|
|
}" |
|
|
> |
|
|
> |
|
@ -98,6 +96,18 @@ defineExpose({ |
|
|
.button-disabled { |
|
|
.button-disabled { |
|
|
opacity: 0.5; |
|
|
opacity: 0.5; |
|
|
} |
|
|
} |
|
|
|
|
|
.my-button-small { |
|
|
|
|
|
height: 25px; |
|
|
|
|
|
font-size: 12px; |
|
|
|
|
|
padding: 3px 15px; |
|
|
|
|
|
.el-icon { |
|
|
|
|
|
position: absolute; |
|
|
|
|
|
left: 3px; |
|
|
|
|
|
svg { |
|
|
|
|
|
width: 25px; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
.my-button-default { |
|
|
.my-button-default { |
|
|
background: #fff; |
|
|
background: #fff; |
|
|
color: $primary-color; |
|
|
color: $primary-color; |
|
|