Vue之七导航守卫
{ path:'/',component:Recommend,beforeEnter: (to, from, next) => { console.log(to); ajax('get','/api/mall/categoryList',true,'',res=>{ var data=res.data; if(data[0].categoryName=="推荐"){ next({path:'/Recommend',query:{categoryId:data[0].categoryId}}) }else if(data[0].categoryName=="房卡"){ next({path:'/RoomCard',query:{categoryId:data[0].categoryId}}) }else if(data[0].categoryName=="钻石"){ next({path:'/Diamonds',query:{categoryId:data[0].categoryId}}) }else if(data[0].categoryName=="金币"){ next({path:'/Gold',query:{categoryId:data[0].categoryId}}) }else if(data[0].categoryName=="礼包"){ next({path:'/Package',query:{categoryId:data[0].categoryId}}) }else if(data[0].categoryName=="道具"){ next({path:'/Prop',query:{categoryId:data[0].categoryId}}) } }) } },
你要觉得这篇文章比较好,记得点推荐!