mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 05:51:44 +03:00
1 parent
a049d1c519
commit
62ab0bf92f
1 file changed
+9
-12
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { type RouteLocationRaw, RouterLink } from 'vue-router';
|
import { type RouteLocationRaw } from 'vue-router';
|
||||||
import { useTheme } from './c-link.theme';
|
import { useTheme } from './c-link.theme';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -11,21 +11,18 @@ const props = defineProps<{
|
|||||||
const { href, to, target } = toRefs(props);
|
const { href, to, target } = toRefs(props);
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const tag = computed(() => {
|
|
||||||
if (href?.value) {
|
|
||||||
return 'a';
|
|
||||||
}
|
|
||||||
if (to?.value) {
|
|
||||||
return RouterLink;
|
|
||||||
}
|
|
||||||
return 'span';
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<component :is="tag" :href="href ?? to" class="c-link" :to="to" :target="target">
|
<a v-if="href" :href="href" class="c-link" :target="target">
|
||||||
<slot />
|
<slot />
|
||||||
</component>
|
</a>
|
||||||
|
<router-link v-else-if="to" :to="to" class="c-link" :target="target">
|
||||||
|
<slot />
|
||||||
|
</router-link>
|
||||||
|
<span v-else class="c-link">
|
||||||
|
<slot />
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
Reference in new issue
Block a user