在我的Nuxt.js应用程序中,我根据documentation的建议安装了 nuxt-i18n :
{
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' }
该如何解决?
答案 0 :(得分:2)
如果您设置默认语言环境,它就可以正常工作:)
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
}]
],
答案 1 :(得分:2)
为使@Nicolas Pennec -great-答案完整,并避免出现警告消息:Locale ISO code is required to generate alternate link
,我们应按documentation中所述声明语言环境:< / p>
// nuxt.config.js
['nuxt-i18n', {
locales: [
{
code: 'en',
iso: 'en-US'
},
{
code: 'es',
iso: 'es-ES'
},
{
code: 'fr',
iso: 'fr-FR'
}
]
}]