你好,我有以下配置

nuxt.config.js

router: {
  middleware: ['auth'],
} 
auth: {
  redirect: {
    login: '/login',
    logout: '/login',
    home: '/',
  },
  strategies: {
    cookie: {
      options: {
        httpOnly: true,
        path: '/',
      },
      user: {
        property: false,
        autoFetch: false,
      },
      endpoints: {
        login: { url: '/api/login', method: 'post' },
        logout: { url: '/api/logout', method: 'post' },
      },
    },
  },
},

而我的家居组件是不需要记录的,所以我设置:

export default {
  name: 'IndexComponent',
  middleware: 'auth',
  auth: false,
}

但是,当我try 访问/auth时,它总是重定向到/登录.

当我点击时,什么都不会发生,控制台中也不会显示任何内容.

我怎么才能解决这个问题?

推荐答案

the documentation年里,它说

在全局使用的情况下,您可以在特定组件中将auth选项设置为FALSE,中间件将忽略该路由.

But by "component", they mean a .vue component.
In our case, since we're using Nuxt it still needs to be a page (hence a route in the /pages/ directory) because this is logical from a router aspect.

Vue.js相关问答推荐

在 Ajax 函数中访问 Vue.js 组件属性

如何在 A-La-Carte 系统中使用 vuetify 加载程序时导入 vuetify/lib

CssSyntaxError 使用 Webpack 4 构建未知单词

VueJS中的绑定函数含义

使用 jquery-chosen 插件更新 vuejs 模型值

如何为 Vue 应用提供 robots.txt

查看 cli3 启用 CORS

如何将 vue.js 与 gulp 一起使用?

如何为 Vue 项目设置 lint-staged?

Vue-Router 抽象父路由

单击链接会更改 url,但不会更改页面上的内容/数据

Vue.js 如果在视图中

store 的 Vuex Classic 模式已弃用,将在 Nuxt 3 中删除

为什么 vue 文档说 refs 不是响应式的,而实际上它们是响应式的

安装后运行computed计算函数

我可以使用react路由创建别名路由吗?

有没有办法知道组件实例何时挂载?

try 通过 Vue.js 中的渲染传递props并观察它们

Vue.js 单向绑定表单

如何使用 Vuetify 验证复选框组