[Vuejs]-Can't get the vue router to work properly

0👍

It is not entirely clear what the firstUsers are. I will assume what you did is intentional and there are two firstUsers (one view and one component).

Specify the to prop of the router-link component as you would the href attribute of a link/anchor <a> element. That is, the route needs to begin with a slash.

<router-link to="/firstUser">

Alternatively, you might want to reduce the coupling by declaring the link by route name instead. This way, you can change the route to whatever you want without having to update your link. This can be done by using v-bind to tell Vue to parse the prop contents, and by using different syntax.

<router-link :to="{ name: 'firstUser' }">

See the Vue Router documentation.

Leave a comment