代码之家  ›  专栏  ›  技术社区  ›  Billal Begueradj

Nuxt.js:消息:“找不到此页”(Nuxt-i18n)

  •  0
  • Billal Begueradj  · 技术社区  · 6 年前

    在我的Nuxt.js应用程序中,我安装了 nuxt-i18n型 documentation 建议:

    {
      modules: [
        ['nuxt-i18n', {
          // Options
        }]
      ]
    }
    

    但是,当我运行npm run dev时,会收到以下错误消息:

     DONE  Compiled successfully in -4519ms                                12:53:52                                                                                         
    
    
     OPEN  http://localhost:3000                                                                                                                                            
    
      nuxt:render Rendering url / +0ms                                                                                                                                      
    { statusCode: 404,                                                                                                                                                      
      path: '/',                                                                                                                                                            
      message: 'This page could not be found' }  
    

    如何解决这个问题?

    2 回复  |  直到 6 年前
        1
  •  3
  •   Nicolas Pennec    6 年前

    如果您设置一个默认的区域设置,它可以正常工作:)

      modules: [
        ['nuxt-i18n', {
          locales: ['en', 'fr', 'es'],
          defaultLocale: 'en',
          seo: false // workaround to fix the current issue on module https://github.com/nuxt-community/nuxt-i18n/issues/127
        }]
      ],
    
        2
  •  4
  •   Billal Begueradj    6 年前

    为了完成@Nicolas Pennec-great-answer,并避免出现以下警告信息: Locale ISO code is required to generate alternate link documentation :

    // nuxt.config.js
    
    ['nuxt-i18n', {
      locales: [
        {
          code: 'en',
          iso: 'en-US'
        },
        {
          code: 'es',
          iso: 'es-ES'
        },
        {
          code: 'fr',
          iso: 'fr-FR'
        }
      ]
    }]
    
    推荐文章