This time I will bring you the precautions to determine whether the page is logged in and whether the page is logged in. The following is a practical case, let's take a look.
is as follows:
router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.requireAuth)){ // 判断该路由是否需要登录权限 if (token) { // 判断当前的token是否存在 next(); } else { next({ path: '/login', query: {redirect: to.fullPath} // 将跳转的路由path作为参数,登录成功后跳转到该路由 }) } } else { next(); } });
attribute to the route:
{ path: '/index', meta: { title: '', requireAuth: true, // 添加该字段,表示进入这个路由是需要登录的 }, }
Note: But the fact is that most of the time there is no jump when logging in, so you need to add a section to the login jump path:
if(this.$route.query.redirect){ // let redirect = decodeURIComponent(this.$route.query.redirect); let redirect = this.$route.query.redirect; this.$router.push(redirect); }else{ this.$router.push('/'); }
Fixed table header makes the form scroll horizontally
Bootstrap drop-down plug-in dropdown usage tips
The above is the detailed content of Determine whether the page is logged in. For more information, please follow other related articles on the PHP Chinese website!