[Vuejs]-Vue 2: URL not refreshing properly the second time

0👍

Well, I found the problem.
This was my link:

<a href="#" class="btn btn-primary" @click="selectProject(project.id)">Select</a>

This was the code of select project:

public selectProject(id:number){
   this.$router.push("project/"+id);
}

By default, Vue executes the “click” method and then the “href” of the link, in my case, redirecting to “#”. Becase there is no id after the # was only redirected once, but the address was replaced.

Solution:

<a href="#" class="btn btn-primary" @click.prevent="selectProject(project.id)">Select</a>

Leave a comment