1
0
mirror of https://github.com/sendevia/website.git synced 2026-03-05 23:32:45 +08:00

feat(button): refactor button component to use dynamic component for anchor and button elements

This commit is contained in:
2025-11-15 00:08:15 +08:00
parent 29364f4c20
commit d9eadf1893

View File

@@ -18,18 +18,17 @@ const props = withDefaults(defineProps<Props>(), {
</script>
<template>
<a v-if="href" :href="href" :target="target" class="md-button" :class="[props.shape, props.size, props.color, props.icon ? 'icon' : '']">
<component
:is="href ? 'a' : 'button'"
:href="href"
class="md-button"
:class="[props.shape, props.size, props.color, props.icon ? 'icon' : '']"
>
<span v-if="props.icon">
{{ props.icon }}
</span>
{{ props.text }}
</a>
<button v-else class="md-button" :class="[props.shape, props.size, props.color, props.icon ? 'icon' : '']">
<span v-if="props.icon">
{{ props.icon }}
</span>
{{ props.text }}
</button>
</component>
</template>
<style lang="scss" scoped>