在 api.onPageChange 事件中获取当前路由名称

您好,各位,

我想在 api.onPageChange 事件中获取当前路由名称。

    api.onPageChange((url, title) =>{
     
    console.log("Current Route name")
  
  
    });

在此函数中,我想要当前路由名称。可以获取到吗?

api.onPageChange((url, title) =>{
  const router = api.container.lookup('service:router');
  console.log(router.currentRoute.name);
}
2 个赞

非常感谢你,理查德。你拯救了我的一天 :star_struck:

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.