0

是否可以在当前 URL 上发出路由,即让 page.js 在当前路径上调用相应的回调?

用例是如果用户正在登录/退出我的应用程序,我希望 page.js 然后在当前路径上路由,因为当前路由可能会根据身份验证状态显示不同的视图。

我正在使用 Riot.js 路由器,只是切换到利用一些 page.js 功能,但 page.js 似乎缺少 Riot.js 拥有的这个核心功能(请参阅此处)。

ps 目前我的解决方法很简单location.reload(),但这并不理想。

4

1 回答 1

1

You can cause Page to route to any arbitrary URL by simply calling page with the URL.

So in your case, you might try:

page( location.pathname );

Or if you have some other method of maintaining a method of what route you're currently on:

page( someStorageMechanism.currentRoute );

However, location.reload(); is unlikely to ever break. I would personally consider this ideal, rather than less than ideal. Why not use the native browser behaviors?

于 2017-07-12T04:01:57.427 回答