1. 程式人生 > >Vue之七導航守衛

Vue之七導航守衛

scrip name diamond 金幣 query ons nds div from

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

  

Vue之七導航守衛