阻止路由器导航 [英] Preventing router from navigating
问题描述
如果进行了一些更改,我需要防止路由器导航到另一个页面(这是通过更改哈希完成的).尝试使用 HashChanger 但它只是触发 'hashChange' 事件而无法防止它冒泡.答案可以在 JS-Signals 库中,但不能直接用于用户创建的 SAP 组件.
I need to prevent router to be navigated to another page (which is done by changing the hash) if some changes are made. Tried with HashChanger but it just fires 'hashChange' events with no way to prevent it from bubbling. The answer can be inside of JS-Signals library but it's unavailable directly for user-created SAP components.
推荐答案
路由器上有停止功能https://sapui5.hana.ondemand.com/#/api/sap.ui.core.routing.Router/methods/stop
如果你调用它,路由器将停止监听 hashchanges.
if you call it, the router will stop listening to hashchanges.
还有函数 isStopped().要(重新)激活路由器,请调用 initialize(...).
There is also function isStopped(). To (re-)activate the router, call initialize(...).
这篇关于阻止路由器导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!