I need help with Vue.js and the NavigationDuplicated error. I am developing a web application where I allow the user to navigate among different pages.
I get "NavigationDuplicated" error even though I am not pushing the same web page. Specifically, the error I get is:
message: "Navigating to current location ("/faq/new") is not allowed", name: "NavigationDuplicated", ...
My router code is the following:
import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/HomeView.vue";
import KBView from "../views/KBView.vue";
import FaqDetailView from "../views/FaqDetailView.vue";
import NewFaqView from "../views/NewFaqView.vue";
Vue.use(VueRouter);
const routes = [
{
path: "/",
name: "Home",
component: HomeView
},
{
path: "/kb",
name: "Knowledge Base",
component: KBView
},
{
path: "/faq/:id",
name: "Faq details",
component: FaqDetailView
},
{
path: "/faq/new",
name: "New faq",
component: NewFaqView
}
];
const router = new VueRouter({
routes
});
export default router;
In each View, there is a button that is redirecting to another View. For example, once a button is clicked, is executed the following code:
this.$router.push({ name: "Knowledge Base" });
this.$router.push({ name: "New faq" })
I get the error with, for example, the following history of routes:
- localhost:8080/#/kb
- localhost:8080/#/faq/new
- localhost:8080/#/kb
- localhost:8080/#/faq/new ---> Here i get the NavigationDuplicated error
In this pic, you can see the history of routes registered by Vue extension for Chrome: Routes history
Could you help me in understanding why I get the "NavigationDuplicated" error? How can I fix this problem?