1

如何在 nuxt-i18n 下同时使用以下 nuxt-links:

<nuxt-link :to="switchLocalePath('en')">EN</nuxt-link>

<nuxt-link :to="localePath('/about')">About</nuxt-link>

因此,当我更改语言时,它会自动将我丢到关于页面。

4

2 回答 2

1

谢谢你的建议!

不幸的是,nuxt-link 似乎不能与@click 一起使用,但是当我嵌套它时可以正常工作,如下所示:

<div @click="$router.push(localePath('/about'))">
    <nuxt-link class="text-header-bold text-middle" :to="switchLocalePath('en')">EN</nuxt-link>
</div>
于 2021-05-09T16:44:11.863 回答
1

您可能可以@click在这样的链接上使用 a

<nuxt-link :to="switchLocalePath('en')" @click="$router.push(localePath('/about'))">EN</nuxt-link>

取自此来源的想法:https ://github.com/nuxt-community/i18n-module/issues/476#issuecomment-539451906

于 2021-05-09T15:12:46.207 回答