[Vuejs]-Vue 2: Using router-link, but button stays on page?

0👍

As mentioned in the documentation

router-view will display the component that corresponds to the URL.
You can put it anywhere to adapt it to your layout.

As per the above definition, your button is in the same file where your router-view is. That means every route’s component will render where <router-view> is and so does would have the button at the top.

So, a solution would be-

  1. Create a home route that will render a Home.vue component and put your <router-link> there.
  2. In App.vue, leave only router-view.

Leave a comment