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);
}
]
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
}
}
]
}
]
})