c540c91bd1f6d54fe0a1d9ffcf50ebb9b90a6d19.svn-base 603 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <!-- eslint-disable vue/require-component-is -->
  3. <component v-bind="linkProps(to)">
  4. <slot />
  5. </component>
  6. </template>
  7. <script>
  8. import { isExternal } from '@/utils/validate'
  9. export default {
  10. props: {
  11. to: {
  12. type: String,
  13. required: true
  14. }
  15. },
  16. methods: {
  17. linkProps(url) {
  18. if (isExternal(url)) {
  19. return {
  20. is: 'a',
  21. href: url,
  22. target: '_blank',
  23. rel: 'noopener'
  24. }
  25. }
  26. return {
  27. is: 'router-link',
  28. to: url
  29. }
  30. }
  31. }
  32. }
  33. </script>