<!-- 解析路径并跳转路由 -->
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { RouterLink } from 'vue-router'
import { isExternal } from '@/utils/validate'

const props = defineProps({
  to: {
    type: String,
    required: true
  }
})

const isExtLink = computed(() => isExternal(props.to))

onMounted(()=>{
  // console.log(props.to,'111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111')
  
})
</script>

<template>
  <a v-if="isExtLink" :href="to" target="_blank" rel="noopener">
    <slot />
  </a>
  <router-link v-else :to="to">
    <slot />
  </router-link>
</template>
