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}})
				}
			})
      }
 	},

  

posted @ 2018-01-18 18:45  地铁程序员  阅读(312)  评论(0编辑  收藏  举报