【问题标题】:Can I access nuxt context in nuxt.config.js?我可以在 nuxt.config.js 中访问 nuxt 上下文吗?
【发布时间】:2020-07-12 04:42:21
【问题描述】:

我正在使用nuxt-i18n@nuxtjs/auth,我想像这样配置auth.redirect 选项来支持i18n:

// nuxt.config.js

export default {
  modules: [
    '@nuxtjs/auth',
    'nuxt-i18n',
    // ...
  ],
  auth: {
    redirect: {
      home: localePath('/dashboard'),
      // ...
    },
  },
  // ...
};

通常,就像this.$store一样,我可以通过应用程序实例访问nuxt-i18n提供的localePath函数或context,如this.$localePathapp.localePath。但是怎么在nuxt.config.js文件里面使用呢?

【问题讨论】:

    标签: javascript vue.js nuxt.js nuxt-i18n


    【解决方案1】:

    如果 @nuxt/auth 模块存在 i18n 重定向支持问题,我找到了解决方法:https://github.com/nuxt-community/auth-module/issues/1116#issuecomment-824814739

    信用@azrikahar

    【讨论】:

      猜你喜欢
      • 2019-06-13
      • 2016-05-25
      • 2011-08-14
      • 1970-01-01
      • 2021-06-27
      • 1970-01-01
      • 2018-01-24
      • 2023-03-25
      • 1970-01-01
      相关资源
      最近更新 更多