Skip to content

Export RouterLink component #3466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebamarynissen opened this issue Feb 1, 2021 · 2 comments
Closed

Export RouterLink component #3466

sebamarynissen opened this issue Feb 1, 2021 · 2 comments

Comments

@sebamarynissen
Copy link

What problem does this feature solve?

I have a use case where I want to implement a custom <nav-link> component that builds on top of <router-link>. While this is perfectly possible, it requires me to replace all my <router-link> references with <nav-link> (and I have about 200 of them). Therefore it would be useful to be able to explicitly reference Vue Router's <router-link> in the <nav-link> component so that I can globally register my component as

import Vue from 'vue';
import Router from 'vue-router';
import NavLink from './nav-link.vue';

Vue.install(Router);
Vue.component('router-link', NavLink);

What does the proposed API look like?

I propose to explicitly export the <router-link> component (and perhaps <router-view> as well) so it can be imported like this:

// # nav-link.vue
<template>
  <router-link>
    <slot></slot>
  </router-link>
</template>

<script>
import { RouterLink } from 'vue-router';

export default {
  components: {
    RouterLink,
  },
};
</script>

I will file a PR for this.

@posva
Copy link
Member

posva commented Feb 1, 2021

Duplicate of #1976

@posva posva marked this as a duplicate of #1976 Feb 1, 2021
@posva posva closed this as completed Feb 1, 2021
@sebamarynissen
Copy link
Author

sebamarynissen commented Feb 1, 2021

My apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants