我使用nuxt-i18n在我的应用程序中获得国际化。我有一条新闻清单,列出了这样的路线:
//method in MainActivity
private static Fragment fragment;
public void setFragment(Fragment fragment){
this.fragment = fragment;
}
//And from your fragment class, you can call
((<yourActivity in which fragment present>)getActivity()).setFragment(<your fragment object>);
//if you want to set it directly;
((<yourActivity in which fragment present>)getActivity()).fragment=<your fragment object>;
当我单击新闻时,我想进入_id页面,仅获得我单击的新闻。所以我用一种方法(onclick)做到了这一点:
myapp.com/news (default language english)
myapp.com/fr/news
myapp.com/it/news
但是通过这种方式,我总是返回英语默认语言。如何以这种方式推送语言环境路由(在方法函数中)?
答案 0 :(得分:3)
this。$ router.push(this.localePath({name:“ news-id”,params:{id}})));
之所以有效,是因为我有一个文件夹“ news”,并且在两个vue页面中都有index.vue和_id.vue。