mirror of
https://github.com/strapi/strapi.git
synced 2025-07-18 14:32:56 +00:00
33 lines
540 B
Vue
33 lines
540 B
Vue
![]() |
<template>
|
||
|
<component v-bind="linkProps(to)">
|
||
|
<slot></slot>
|
||
|
</component>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
props: {
|
||
|
to: {
|
||
|
type: String,
|
||
|
required: true
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
linkProps (url) {
|
||
|
if (url.match(/^(http(s)?|ftp):\/\//)) {
|
||
|
return {
|
||
|
is: 'a',
|
||
|
href: url,
|
||
|
target: '_blank',
|
||
|
rel: 'noopener'
|
||
|
}
|
||
|
}
|
||
|
return {
|
||
|
is: 'router-link',
|
||
|
to: url
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|