vue项目根据url语言配置国际化

url .../en/xxx .../fr/xxx
像这种url怎么在router里配置
现在的router是这样的
目前了解到可以在beforeRouterEnter设置i18n状态,但是应该怎么从url上获取到语言参数
`
new Router({

base: "/",
mode: 'history',
routes: [
    {
        base: "/",
        mode: 'history',
        routes: [
            {
                path: '/',
                name: 'Base',
                component: Base,
                children: [
                    {
                        path: '/',
                        name:  'home',
                        component:  home
                    },
                ]
            }
        ]
    }
]

})
`

阅读 2.4k
1 个回答
新手上路,请多包涵

配置路由的时候
{
path: '.../:lang/xxx'
}

image.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题