全局导航钩子

//是否需要判断实名认证的路由

router.beforeEach((to,from,next) => {
  var pageList=['list','me'];
  Array.prototype.isData=function(e){
    var r=new RegExp(','+e+',');
    return (r.test(','+this.join(this.S)+','));
  };
  if(pageList.isData(to.name)){
    console.log('要判断的路由');
    console.log(store);
    if(store.state.fundcode.isReal){
      next();
    }else{
      next({path:'/要跳的路由'});
    }}else{
    next();
  }
});
111

你可能感兴趣的:(全局导航钩子)