12 changed files with 191 additions and 261 deletions
@ -1,41 +1,39 @@ |
|||||
<template> |
<template> |
||||
<Button v-bind="getBindValue" :class="getButtonClass" @click="onClick"> |
<Button v-bind="getBindValue" :class="getButtonClass" @click="onClick"> |
||||
<template #default> |
<template #default="data"> |
||||
<Icon :icon="preIcon" v-if="preIcon" :size="iconSize" /> |
<Icon :icon="preIcon" v-if="preIcon" :size="iconSize" /> |
||||
<slot></slot> |
<slot v-bind="data || {}"></slot> |
||||
<Icon :icon="postIcon" v-if="postIcon" :size="iconSize" /> |
<Icon :icon="postIcon" v-if="postIcon" :size="iconSize" /> |
||||
</template> |
</template> |
||||
</Button> |
</Button> |
||||
</template> |
</template> |
||||
|
|
||||
<script lang="ts"> |
<script lang="ts"> |
||||
import { defineComponent, computed, unref } from 'vue'; |
export default { |
||||
|
name: 'AButton', |
||||
|
inheritAttrs: false, |
||||
|
}; |
||||
|
</script> |
||||
|
<script lang="ts" setup> |
||||
|
import { computed, unref } from 'vue'; |
||||
import { Button } from 'ant-design-vue'; |
import { Button } from 'ant-design-vue'; |
||||
import Icon from '/@/components/Icon/src/Icon.vue'; |
import Icon from '/@/components/Icon/src/Icon.vue'; |
||||
import { buttonProps } from './props'; |
import { buttonProps } from './props'; |
||||
import { useAttrs } from '/@/hooks/core/useAttrs'; |
import { useAttrs } from '/@/hooks/core/useAttrs'; |
||||
|
|
||||
export default defineComponent({ |
const props = defineProps(buttonProps); |
||||
name: 'AButton', |
// get component class |
||||
components: { Button, Icon }, |
const attrs = useAttrs({ excludeDefaultKeys: false }); |
||||
inheritAttrs: false, |
const getButtonClass = computed(() => { |
||||
props: buttonProps, |
const { color, disabled } = props; |
||||
setup(props) { |
return [ |
||||
// get component class |
{ |
||||
const attrs = useAttrs({ excludeDefaultKeys: false }); |
[`ant-btn-${color}`]: !!color, |
||||
const getButtonClass = computed(() => { |
[`is-disabled`]: disabled, |
||||
const { color, disabled } = props; |
}, |
||||
return [ |
]; |
||||
{ |
|
||||
[`ant-btn-${color}`]: !!color, |
|
||||
[`is-disabled`]: disabled, |
|
||||
}, |
|
||||
]; |
|
||||
}); |
|
||||
|
|
||||
// get inherit binding value |
|
||||
const getBindValue = computed(() => ({ ...unref(attrs), ...props })); |
|
||||
|
|
||||
return { getBindValue, getButtonClass }; |
|
||||
}, |
|
||||
}); |
}); |
||||
|
|
||||
|
// get inherit binding value |
||||
|
const getBindValue = computed(() => ({ ...unref(attrs), ...props })); |
||||
</script> |
</script> |
||||
|
|||||
Loading…
Reference in new issue