vue 路由拦截、axios请求拦截
路由拦截 项目中,有些页面需要登录后才能进入,例如,在某页面A,用户在操作前需要先进入登录页(此时需要将上一页的地址( /survey/start )作为query存入login页面的地址中,如: http://localhost:8071/#/login?redirect=%2Fsurvey%2Freport ),登录成功后再进入页面A。 首先,在router.js中创建路由时,给需要登录的路由中的 meta 添加字段:requireLogin,如下: const router = new Router({ routes: [ { path: '/login', name: 'Login', component: Login, meta: { title: '登录页' } }, { path: '/register', name: 'Register', component: Register, meta: { title: '注册页' } }, { path: '/', redirect: '/survey/start', name: 'Full', component: Full, children: [ { path: '/survey/start', name: 'Home', component: Home, meta: { title: '首页',