全局路由守卫

66 阅读1分钟

全局前置守卫

import Vue from 'vue'
import Router from 'vue-router'
import indexCommon from './index_common' //公共模块路由
Vue.use(Router);
let router = new Router({
	linkActiveClass: 'is-active',
	routes:[{
		path: '/qualityDangerForm',
		component: qualityDangerForm,
		meta: {
			title: '页面标题'
		}
    }]
})
    
/* ------进入页面改变title ------*/
router.beforeEach((to, from, next) => {
	if (to.meta.title) {
        document.title = to.meta.title
	}
	if ( true ) {
    	next()   
	} else {
		// ...
		// 返回 false 以取消导航
        return false
    }
  
});
/* ------//进入页面改变title ------*/
 
export default router