简体   繁体   English

路由绝对路径不适用于嵌套路由

[英]Routify Absolute Paths not working with nested routes

Moved a sapper appliacation to svelte/routify.将一个工兵应用程序移动到 svelte/routify。 Overall, I like the structure better, but I am having issues with absolute paths.总的来说,我更喜欢这种结构,但我遇到了绝对路径的问题。

I have a Nav bar which has the following links我有一个导航栏,其中包含以下链接

  1. Home
  2. About关于
  3. Items项目

and I have another route that is not in the Nav, that is a nested dynamic route for Items [item].svelte .我还有另一条不在导航中的路线,即 Items [item].svelte的嵌套动态路线。

Naviagtion works fine, but whenever I hit the nested dyanmic route www.example.com/items/item , I get the page, but cannot navigate back to the other "parent"/ non nested pages. Naviagtion 工作正常,但是每当我点击嵌套动态路由www.example.com/items/item时,我都会获得该页面,但无法导航回其他“父”/非嵌套页面。

So, when clicking a link once, and I reach that nested route, the url path ( in the browser search bar ) changes to the proper path ( ie going from www.example.com/items/item to www.example.com/about , but the about page wont load. of course, from this stage, reloading the page makes the page appear.因此,当单击一次链接并到达该嵌套路径时,url 路径(在浏览器搜索栏中)更改为正确的路径(即从www.example.com/items/itemwww.example.com/about ,但是 about 页面不会加载。当然,从这个阶段开始,重新加载页面会使页面出现。

My nav links look like... <a href="/items"... > and <a href="/about"... > , and so on.我的导航链接看起来像... <a href="/items"... ><a href="/about"... >等等。

Thank you in advance for the help.预先感谢您的帮助。

try using the url helper method instead of direct hrefs.尝试使用 url 辅助方法而不是直接 href。

<a class="nav-link" href={$url('./irrigation')}>Irrigation <a class="nav-link" href={$url('./irrigation')}>灌溉

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM