首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Framework7路由保护

Framework7路由保护
EN

Stack Overflow用户
提问于 2018-09-05 21:24:13
回答 1查看 460关注 0票数 0
代码语言:javascript
复制
import HomePage from './pages/home.vue';
import Home2Page from './pages/home2.vue';
import NotFoundPage from './pages/not-found.vue';

export default [
  {
    path: '/',
    component: HomePage,
    // check if the user is logged in
    beforeEnter: checkAuth,
  },
  {
    path: '/home2',
    component: Home2Page,
  },
  {
    path: '(.*)',
    component: NotFoundPage
  }
];


function checkAuth(to, from, resolve, reject) {
  if (true) {
    resolve({
      component: Home2Page
    });
  } else {
    reject();
  }
}

为什么此checkAuth函数不起作用?我尝试检查页面是否需要Auth,当它需要checkAuth应该启动的函数时。如果在这种情况下Auth为true,则应加载另一个页面。

EN

回答 1

Stack Overflow用户

发布于 2018-09-06 16:28:47

您必须使用redirect属性而不是beforeEnter

示例(retrieved from the docs):

代码语言:javascript
复制
redirect: function (route, resolve, reject) {
  if (true) {
    resolve('myUrl');
  }
  else reject();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52186266

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档