Files
jiangmingzhao-daily-report/frontend/src/layout/components/Sidebar/Link.vue

38 lines
576 B
Vue
Raw Normal View History

<template>
<component :is="linkProps.is" v-bind="linkProps.props">
<slot />
</component>
</template>
<script setup>
import { computed } from 'vue'
import { isExternal } from '@/utils/validate'
const props = defineProps({
to: {
type: String,
required: true
}
})
const linkProps = computed(() => {
if (isExternal(props.to)) {
return {
is: 'a',
props: {
href: props.to,
target: '_blank',
rel: 'noopener'
}
}
}
return {
is: 'router-link',
props: {
to: props.to
}
}
})
</script>