[英]Make Routify use #hash
I'm using this Svelte router - https://routify.dev/我正在使用这个 Svelte 路由器 - https://routify.dev/
It works fine but I can't get it to work with hashes instead of regular paths.它工作正常,但我无法使用散列而不是常规路径。
In the examples I've changed the nav to ["./#index", "Home"],
and it changes the address bar but the router no longer reacts to the change.在示例中,我将导航更改为
["./#index", "Home"],
它更改了地址栏,但路由器不再对更改做出反应。
I'm very new to Svelte and Routify so I wouldn't even know where to start from.我对 Svelte 和 Routify 很陌生,所以我什至不知道从哪里开始。 There isn't much in the Docs either.
文档中也没有太多内容。 Thanks!
谢谢!
As shown in this post you just need to change your router component tag to <Router config={{useHash: true}} {routes} />
in the src/App.svelte file.如本文所示,您只需将 src/App.svelte 文件中的路由器组件标签更改为
<Router config={{useHash: true}} {routes} />
。
All of the links that use the url helper will automatically get the hash.所有使用url helper的链接都会自动获取哈希值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.