mirror of
https://github.com/strapi/strapi.git
synced 2025-07-14 04:21: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>
|