如何在 nuxt-i18n 下同时使用以下 nuxt-links:
<nuxt-link :to="switchLocalePath('en')">EN</nuxt-link>
和
<nuxt-link :to="localePath('/about')">About</nuxt-link>
因此,当我更改语言时,它会自动将我丢到关于页面。
谢谢你的建议!
不幸的是,nuxt-link 似乎不能与@click 一起使用,但是当我嵌套它时可以正常工作,如下所示:
<div @click="$router.push(localePath('/about'))">
<nuxt-link class="text-header-bold text-middle" :to="switchLocalePath('en')">EN</nuxt-link>
</div>
您可能可以@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