【问题标题】:Redirect to locale with Nuxtjs and i18n on SPA mode在 SPA 模式下使用 Nuxtjs 和 i18n 重定向到语言环境
【发布时间】:2021-10-06 05:48:10
【问题描述】:

当我在 SPA 模式下生成 Nuxtjs (SSR: false) 时,nuxt 生成了没有 index.html 文件的 dist。

所以我有两个问题

第一个:我需要重定向到 lang 文件夹 ex。 exmple.com 重定向到 exmaple.com/{locale}

第二个:我需要重定向子页面。 exmple.com/admin 重定向到 exmaple.com/{locale}/admin

// nuxt.config.js
...
  i18n: {
    lazy: true,
    langDir: 'lang/',
    locales: [
      {
        code: 'en',
        iso: 'en-US',
        file: 'en.js',
        name: 'English'
      },
      {
        code: 'ar',
        iso: 'ar-EG',
        file: 'ar.js',
        name: 'عربى'
      }
    ],
    defaultLocale: {
      locale: 'en',
      prefix: true
    },
...

【问题讨论】:

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


    【解决方案1】:

    我有一个想法来解决这个问题,但我不知道这是否是最好的解决方案。

    只需使用.htaccess 处理请求并返回我需要的索引。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      相关资源
      最近更新 更多