When vue tab closes the tab, the home page is displayed by default.

the effect I want to achieve is that when I delete the last tag, I show the template on the home page. I use $router.push, but it doesn"t work. I can use $router.go, directly but refresh the page. Solve?

if(this.mainNav.length == 0){
                        console.log(this.$router);
                        this.$router.push("/mean/home");
                    }else{
                        this.$router.go(-1);
                    }

clipboard.png
]

clipboard.png

closeTab:function(name){
            for(var i = 0; i< this.mainNav.length;iPP){
                if(this.mainNav[i].name == name){
                    this.mainNav.splice(i,1);
                    if(this.mainNav.length == 0){
                        console.log(this.$router);
                        this.$router.push("/mean/home");
                    }else{
                        this.$router.go(-1);
                    }
                    
                }
            }
        }

routing

import Vue from "vue";
import VueRouter from "vue-router";
import login from "@/components/login";
import index from "@/components/module/index";
import list from "@/components/module/list/list";
import listInfo from "@/components/module/list/list-info";
import home from "@/components/module/home";
Vue.use(VueRouter);

export default new VueRouter({
    mode:"history",
    routes:[
        {
            path:"/",
            component:index,
            redirect:"/mean/home"
        },
        {
            path:"/login",
            component:login
        },
        {
            path:"/mean",
            component:index,
            redirect:"/mean/home",
            children:[
                {
                    path:"/mean/home",
                    component:home,
                    meta: { 
                        requiresAuth: true 
                    }
                },
                {
                    path:"/mean/list",
                    component:list,
                    meta: { 
                        requiresAuth: true 
                    }
                },
                {
                    path:"/mean/list/:info",
                    component:listInfo,
                    meta: { 
                        requiresAuth: true 
                    }
                }
            ]
        }
    ]
})
Feb.12,2022

guess your route is like this:

{
        path: '/mean/home',
        name: 'home',
        component: .......,
        //.....
   }

if name is set, try using

this.$router.push({
   name: 'home'
});

this is how we use it. After closing other tabs, the home page is displayed by default, and the home page is not refreshed.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb109e-480e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb109e-480e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?