mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-12-11 18:42:52 +00:00
48 lines
996 B
Vue
48 lines
996 B
Vue
<template>
|
|
<component class="tmagic-design-button" :is="uiComponent" v-bind="uiProps" @click="clickHandler">
|
|
<template #icon v-if="$slots.icon">
|
|
<slot name="icon"></slot>
|
|
</template>
|
|
<template #default v-if="$slots.default">
|
|
<slot></slot>
|
|
</template>
|
|
</component>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
|
|
import { getDesignConfig } from './config';
|
|
import type { ButtonProps } from './types';
|
|
|
|
defineOptions({
|
|
name: 'TMButton',
|
|
});
|
|
|
|
const props = defineProps<ButtonProps>();
|
|
|
|
const ui = getDesignConfig('components')?.button;
|
|
|
|
const uiComponent = ui?.component || 'el-button';
|
|
|
|
const uiProps = computed<ButtonProps>(() => ui?.props(props) || props);
|
|
|
|
const emit = defineEmits(['click']);
|
|
|
|
const clickHandler = (...args: any[]) => {
|
|
emit('click', ...args);
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.tmagic-design-button {
|
|
.t-button__text {
|
|
align-items: center;
|
|
}
|
|
|
|
+ .tmagic-design-button {
|
|
margin-left: 12px;
|
|
}
|
|
}
|
|
</style>
|