router.beforeEach((to, from, next) => {
if (to.matched.length ===0) { //如果未匹配到路由
from.name ? next({ name:from.name }) : next('/'); //如果上級也未匹配到路由則跳轉登錄頁面,如果上級能匹配到則轉上級路由
} else {
next(); //如果匹配到正確跳轉
}
});
